1 ////////////////////////////////////////
5 // 1. Declair the CEvent class that encapsulates the functionality of a
6 // single-locking semaphore.
12 #ifndef BASE_SOLARIS_EVENT_H
13 #define BASE_SOLARIS_EVENT_H
15 #if !defined(_REENTRANT)
16 # pragma message( "Excluding Base::CEvent - requires multi-threaded compile. (_REENTRANT)" )
25 ////////////////////////////////////////
30 // Encapsulates the functionality of a singal-locking semaphore.
31 // This class is valuable for thread syncronization when a thead's
32 // execution needs to be dependent upon another thread.
35 // Signal() : Signals a thread that has called Wait() so that it can
36 // continue execution. This function returns true if the waiting
37 // thread was signalled successfully, otherwise false is returned.
38 // Wait() : Halts the calling thread's execution indefinately until
39 // a Singal() call is made by an external thread. If the thread is
40 // successfully signalled, the function returns eWAIT_SIGNAL. If
41 // timeout period expires without a signal, eWAIT_TIMEOUT is returned.
42 // If the function fails, eWAIT_ERROR is returned.
51 int32
Wait(uint32 timeout
= 0);
53 enum { eWAIT_ERROR
, eWAIT_SIGNAL
, eWAIT_TIMEOUT
};
55 pthread_mutex_t mMutex
;
62 inline bool CEvent::Signal()
66 pthread_mutex_lock(&mMutex
);
69 pthread_cond_signal(&mCond
);
75 pthread_mutex_unlock(&mMutex
);
81 #endif // #if defined(_MT)
83 #endif // BASE_SOLARIS_EVENT_H