Barrier
Summary
Wait for one or more tasks to finish and signal that they are done before starting a dependent task.
It is easy to execute tasks concurrently in LoLo, just route one event to multiple nodes! This function enables you to collect the output from multiple concurrent tasks so that it can be used in a later task.
Ports
You may change the port configuration on this function and it will adapt. There may only be one input port called in
. There must be a output port called out
. There may be additional output ports. Each additional output port represents a task to wait for. The name of the additional ports are used as tags to identify tasks.
When an event is received on the in
port, the event is distributed to each output port (except out
). Once a each task has signaled that it is done, an event is routed to the out
port.
Input/Output Format
Any value can be recieved on the port in
. The received event is passed as is to the task ports (i.e. not out
).
The event routed to out
will be an object with a property for each awaited task. The task's tag is used as the property name. The value of the property is set to the value passed along when the task signaled it being done. E.g.:
{
a: …,
b: …,
c: …,
…
}
Events
This functions listens for one event per task. These event names are of the form {tag}_done
where {tag}
is a tag, e.g. a_done
. If there are three output ports beside out
called a, b, c, this function will listen for the events a_done
, b_done
, and c_done
.
Any value may be passed along with such event. The value passed along will be collected and routed as explained above.
Other
If there are not other output ports beside out
, then the received event is immediately routed to the out
port as is.
The barrier waits at most for a duration specified in Settings -> Parameters for the tasks to finish. If not all tasks have finished within that time, then the event is dropped.
Updated almost 2 years ago