This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20.6
New signal

New signal 


 

New signal {( description )} -> Function result 
Parameter Type   Description
description  Text in Description for the signal
Function result  Object in Native object encapsulating the signal

The New signal command creates a signal object.

A signal is a shared object which can be passed as parameter from a worker or process to another worker or process, so that:

  • the called worker/process can update the signal object after specific processing has completed
  • the calling worker/process can stop its execution and wait until the signal is updated, without consuming any cpu resources. 

Optionally, in the description parameter you can pass a custom text describing the signal. This text can also be defined after signal creation.

Since the signal object is a shared object (see Shared objects and shared collections), it can also be used to maintain user properties, including the signal.description property, by calling the Use...End use structure.

 

Returned value

The returned signal object contains the following properties and methods:


PropertyTypeDescription
signal.signaledBoolean(read-only property) false at signal creation. Becomes true when the signal.trigger( ) method is called.
signal.descriptionTextCustom description of the signal, if any.

MethodDescription
signal.wait( )Wait for the signal (calling process/worker)
signal.trigger( )Trigger the signal (called process/worker)

Example  

Here is a typical example of a worker that sets a signal:

 C_OBJECT($signal)
 $signal:=New signal("This is my first signal")
 
 CALL WORKER("myworker";"doSomething";$signal)
 $signaled:=$signal.wait(1) //wait for 1 second max
 
 If($signaled)
    ALERT("myworker finished the work. Result: "+$signal.myresult)
 Else
    ALERT("myworker has not finished in less than 1s")
 End if

The "doSomething" method could be like:

 C_OBJECT($1)
  //any processing
  //...
 Use($1)
    $1.myresult:=$processingResult  //return the result
 End use
 $1.trigger() // The work is finished



See also 

signal.description
signal.signaled
signal.trigger( )
signal.wait( )

 
PROPERTIES 

Product: 4D
Theme: Process (Communications)
Number: 1641

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v17 R4

 
ARTICLE USAGE

4D Language Reference ( 4D v20)
4D Language Reference ( 4D v20.1)
4D Language Reference ( 4D v20.2)
4D Language Reference ( 4D v20.3)
4D Language Reference ( 4D v20.4)
4D Language Reference ( 4D v20.5)
4D Language Reference ( 4D v20.6)