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

I. Installation.
II. Threading primitives.
1. Encapsulation of primitives.
2. Preventing starvation.
3. Preventing race condition.
4. Barriers.
A. SignaledBarrier.
B. SignaledCountingBarrier.
C. SignaledCountingBarrier2.
D. Barrier.
III. NonBlockingQueue.
IV. ThreadPool.
V. ThreadMaster.
VI. OTS Scheduler.
VII. Bibliography
Downloads. Index. Contents.

SignaledCountingBarrier.


he SignaledCountingBarrier::waitForOpen() member function blocks every thread that calls it unless the number of threads blocked on this function reaches certain number. If such number is reached then all threads are released and the function returns false for the one thread that arrived last and true for all other threads. Such maximal number of locked threads is dictated by the only parameter of the constructor.

The other functions of the public interface are the SignaledCountingBarrier::openOne() and openAll(). These cause immediate release of one (all) of the threads blocked at waitForOpen() if there is at least one such thread. If there is no such thread then the function has no effect.

The following is the public interface of the SignaledCountingBarrier.

class SignaledCountingBarrier : boost::noncopyable

{

public:

explicit SignaledCountingBarrier( unsigned char nThreads );

bool waitForOpen() volatile;

void openOne() volatile;

void openAll() volatile;

};

The member functions throw either ots::config::ThreadResourceError (=boost::thread_resource_error by default ots::config setting) or ots::ThreadInterrupted (=boost::thread_interrupted).





Downloads. Index. Contents.


















Copyright 2007