Collaboration diagram for AxPipe::CThreadSync:
Public Member Functions
|Initialize sync objects. |
|Clean up. |
|Initiate one Work() cycle - called from outside worker thread. |
|Signal that we've prepared for more Work() - called from outside worker thread. |
|Wait for more to be ready for Work() - this is called in the worker thread. |
|End one Work() cycle - called from the worker thread. |
|Enable serialization of requests for processing, can't use a Mutex, as it's sometimes the same thread we need to control. |
|Signal when worker has work to do. |
|Signal when worker has accepted signal. |
Threads often need synchronized access to shared data, and control the the passing of the data. This class implements methods for this under a 'work' paradigm. Thread A wants to pass off a piece of work in some form of shared medium, i.e. shared memory for example, to thread B. The sequence is then: A B ... WorkWait() ... WorkStart() WorkSignal() ... WorkEnd()
The methods ensure that when WorkStart() returns, no other thread is between WorkStart() and WorkEnd(). It's also guaranteed that when WorkSignal() returns, thread B has received the signal via WorkWait(). Owneship of the shared resource passes from A to B upon return from WorkSignal() and WorkWait() respectively. Thread B relinquishes it's hold, upon call to WorkEnd(), and as previously noted Thread A get's ownership upon return of WorkStart().
Definition at line 75 of file CSync.h.