simmer (version 4.0.0)

send: Inter-arrival Communication

Description

These activities enable asynchronous programming. send() broadcasts a signal or a list of signals. Arrivals can subscribe to signals and (optionally) assign a handler with trap(). Note that, while inside a batch, all the signals subscribed before entering the batch are ignored. Upon a signal reception, the arrival stops the current activity and executes the handler (if provided). Then, the execution returns to the activity following the point of the interruption. untrap() can be used to unsubscribe from signals. wait() blocks until a signal is received.

Usage

send(.trj, signals, delay = 0)

trap(.trj, signals, handler = NULL, interruptible = TRUE)

untrap(.trj, signals)

wait(.trj)

Arguments

.trj

the trajectory object.

signals

signal or list of signals, accepts either a string, a list of strings or a callable object (a function) which must return a string or a list of strings.

delay

optional timeout to trigger the signals, accepts either a numeric or a callable object (a function) which must return a numeric.

handler

optional trajectory object to handle a signal received.

interruptible

whether the handler can be interrupted by signals.

Value

Returns the trajectory object.

See Also

renege_if