Quantitative Analysis.
Trading Platform.
Python for Excel.
Author.
I.Installation.
II.OTS Scheduler.
1.Threading primitives.
A.Encapsulation of primitives.
B.Preventing starvation.
C.Preventing race condition.
D.Barriers.
a.SignaledBarrier.
b.SignaledCountingBarrier.
c.SignaledCountingBarrier2.
d.Barrier.
2.NonBlockingQueue.
3.ThreadPool.
4.ThreadMaster.
5.Scheduler implementation.
III.OTS Python Object Browser.
Bibliography.
Forum Index Contents Downloads

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).





Forum Index Contents Download


















Copyright 2009.