Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AxPipe::CThreadSync Class Reference

A small collection of objects and methods for thread sync. More...

#include <CSync.h>

Collaboration diagram for AxPipe::CThreadSync:

Collaboration graph
List of all members.

Public Member Functions

 CThreadSync ()
 Initialize sync objects.

 ~CThreadSync ()
 Clean up.

void WorkStart ()
 Initiate one Work() cycle - called from outside worker thread.

void WorkSignal ()
 Signal that we've prepared for more Work() - called from outside worker thread.

void WorkWait ()
 Wait for more to be ready for Work() - this is called in the worker thread.

void WorkEnd ()
 End one Work() cycle - called from the worker thread.

Private Attributes

HANDLE m_hSemaphore
 Enable serialization of requests for processing, can't use a Mutex, as it's sometimes the same thread we need to control.

CSync m_Work
 Signal when worker has work to do.

CSync m_Accepted
 Signal when worker has accepted signal.

Detailed Description

A small collection of objects and methods for thread sync.

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.

The documentation for this class was generated from the following files:
Generated on Mon Feb 2 13:19:29 2004 for AxPipe by doxygen 1.3.5