Quantitative Analysis
Parallel Processing
Numerical Analysis
C++ Multithreading
Python for Excel
Python Utilities
Services
Author

I. Installation.
II. Threading primitives.
III. NonBlockingQueue.
IV. ThreadPool.
V. ThreadMaster.
1. ThreadMaster prototypes.
2. Acceptance test for the ThreadMaster.
VI. OTS Scheduler.
VII. Bibliography
Downloads. Index. Contents.

ThreadMaster.


ome task is performed in several consecutive stages. Each stage allows for parallel processing by several working threads. A next stage may not be attempted until all working threads finished processing of the current stage. Such organization of processing is the service provided by the class ThreadMaster.

The precise procedure, performed on every stage, is supplied to the ThreadMaster in form of a boost::function0<void> object (Called "Job" in the code).

After a stage is finished but before the next stage is started the ThreadMaster executes a boost::function0<bool> object on a single thread and terminates if such execution returns "false". The boost::function<bool> object is also supplied by the user. It is called "Condition" in the code.

If at any stage the Job throws exception then such worker thread is restarted and resumes from the same stage. If the operation of starting another thread throws exception (thread number limits or memory problems) then the ThreadMaster stops processing.

If the Condition throws exception then the ThreadMaster restarts the thread. The newly started thread will execute the Job again and evaluate the Condition again.

If the given sequence of stages is exhausted then the ThreadMaster resumes the same processing from the first stage.

The memory management of the ThreadMaster is similar to the management of the boost::thread. The user may allocate ThreadMaster on stack or on heap. The processing will continue until completion after the original ThreadMaster instance is gone. The ThreadMaster has copy-by-value semantics. The copying operation is light. All copies represent the same structure.




1. ThreadMaster prototypes.
2. Acceptance test for the ThreadMaster.

Downloads. Index. Contents.


















Copyright 2007