\"\" \"\" \"\"
Go backward to open(): Open a Bag (Binding Form)
Go up to Constructors
RISC-Linz logo

ThreadBagn: Adding a Thread

ThreadBagn<R, A1, ..., An>(b, f, a1, ..., an)
ThreadBagn<R, A1, ..., An>::create(b, f, a1, ..., an)
ThreadBagn<R, A1, ..., An>::start(b, f, a1, ..., an)
      ThreadBag<R> b
      R (*f)(A1, ..., An)
      Ai ai

Specification: Adds to b a new thread computing f(a1, ..., an).

  1. The first form is equivalent to the second or to the third form.
  2. In the second form, the created thread is put into the lazy stack.
  3. In the third form, the created thread is activated and put into the ready queue.
Constraints: It is illegal to apply this operation if b is unbound or if it is bound to a closed thread that holds already the number of declared threads.

Restrictions: The number of arguments n ranges from 0 to an implementation-dependent constant (currently 4). This range may be extended by defining the corresponding template class.

Note: Only the third form of thread creation by start guarantees the "true" semantics of thread bags, namely that in the ordering of delivered results (Returning the Bag Results) non-terminating threads only appear after all terminating threads. However, if all threads are guaranteed to terminate, the second form is equivalent and in general much more efficient.

Implementation: Normally, the first form is equivalent to the second form. However, if the preprocessor constant RT_TBAG_NOTLAZY is defined before including the header file rt++.h, the first form is equivalent to the third form.


Author: Wolfgang Schreiner
Last Modification: April 12, 1997