The var bridge object stores data during run time, therefore it acts like a bridge to pass data between different threads. This object is also useful for joining threads. Data stored in a var bridge can be persistent, i.e. saved onto disk, or non persistent, i.e. lost when execution is stopped.
Normally all data a thread collects during run time is lost when a thread terminates. Passing data to a var bridge object stores the data so that other threads can access them. The data to be stored is specified via the property dialog. A single var bridge object can store an arbitrary number of variables. The contents of a var bridge can be cleared by calling the "clear" action.
When the "Join threads" option is checked in the property dialog,
the behaviour is a little bit different: When a thread stores some
data in the var bridge, the object checks whether all variables have
data after the storing operation. If this is not the case, the calling
thread is terminated. In the other case all data is copied to the
output variables, the internal buffers are cleared and the thread
continues execution. This is useful to collect data which has been
calculated in parallel, but further on processing should continue in
one single thread. This is especially useful when doing calculations
on multi processor machines where it isn't known which thread
terminates at first, or when thread execution time depends on external
Fig. 1: Two tasks where a var bridge is useful; note the dashed line in the "store data" case, which means that the "continue execution" option in the connection dialog has been switched off Figure 1 shows examples of using the var bridge. In the left case the "DoSomthing2" object is called when the user presses a button. In this object data calculated by "DoSomthing" can be used, as it can be stored into the var bridge. The right example shows a layout where both "DoSomething" object execute parallel. The "Join threads" option must be checked in the var bridge object and the results of the two branches must be stored in two different variables. Then both variables care available for use in the "DoSomthing2" object. This is called when both of the "DoSomething" objects have finished processing. If the "Join threads" option is not checked in this case the "DoSomthing2" object would be called two times.
The normal type of a VarBridge is "Local", which means that data is neither persistent, i.e. written to disk, nor "Foreign", which means that it is got from another VarBridge object.
When using a VarBridge object that gets its data from a "Persistent" VarBridge, reading and storing data is also done when calling the "Foreign" type VarBridge.