Representation
A thread bag of type ThreadBag<T> is represented as
follows:
- A bag handle that references the core bag.
- The core bag which contains one of the following:
- A result list collecting the thread results delivered before the
bag is closed.
- A result array collecting the results of all threads.
- A set of threads delivering their results to the bag.
Initially a bag is in the open state. In this state, it is not known how
many threads the bag will eventually hold; arbitrarily many threads can be
added to the bag. When the bag is eventually closed, only a declared
number of more threads can be added to the bag. During the open state, results
delivered to the bag are collected in the result list. When the bag is closed
(i.e. the final bag size is known) an array is allocated to receive all
thread results, those that have been already collected in the result list, and
those that still remain to be computed.
Author: Wolfgang Schreiner
Last Modification: April 12, 1997