1 ////////////////////////////////////////
5 // 1. Declair the CMutex class that encapsulates the functionality of a
6 // mutually-exclusive device.
12 #ifndef BASE_LINUX_MUTEX_H
13 #define BASE_LINUX_MUTEX_H
15 #if !defined(_REENTRANT)
16 # pragma message( "Excluding Base::CMutex - requires multi-threaded compile. (_REENTRANT)" )
22 #ifdef EXTERNAL_DISTRO
30 ////////////////////////////////////////
35 // Encapsulates the functionality of a mutually-exclusive device.
36 // This class is valuable for protecting against race conditions
37 // within threaded applications. The CMutex class can be used to
38 // only allow a single thread to run within a specified code
42 // Lock() : Locks the mutex. If the mutex is already locked, the
43 // operating system will block the calling thread until another
44 // thread has unlocked the mutex.
45 // Unlock() : Unlocks the mutex.
56 pthread_mutex_t mMutex
;
60 inline void CMutex::Lock(void)
63 pthread_mutex_lock(&mMutex
);
66 inline void CMutex::Unlock(void)
69 pthread_mutex_unlock(&mMutex
);
73 #ifdef EXTERNAL_DISTRO
76 #endif // #if defined(_MT)
78 #endif // BASE_LINUX_MUTEX_H