f@0: #ifndef STK_MUTEX_H f@0: #define STK_MUTEX_H f@0: f@0: #include "Stk.h" f@0: f@0: #if (defined(__OS_IRIX__) || defined(__OS_LINUX__) || defined(__OS_MACOSX__)) f@0: f@0: #include f@0: typedef pthread_mutex_t MUTEX; f@0: typedef pthread_cond_t CONDITION; f@0: f@0: #elif defined(__OS_WINDOWS__) f@0: f@0: #include f@0: #include f@0: typedef CRITICAL_SECTION MUTEX; f@0: typedef HANDLE CONDITION; f@0: f@0: #endif f@0: f@0: namespace stk { f@0: f@0: /***************************************************/ f@0: /*! \class Mutex f@0: \brief STK mutex class. f@0: f@0: This class provides a uniform interface for f@0: cross-platform mutex use. On Linux and IRIX f@0: systems, the pthread library is used. Under f@0: Windows, critical sections are used. f@0: f@0: by Perry R. Cook and Gary P. Scavone, 1995--2014. f@0: */ f@0: /***************************************************/ f@0: f@0: class Mutex : public Stk f@0: { f@0: public: f@0: //! Default constructor. f@0: Mutex(); f@0: f@0: //! Class destructor. f@0: ~Mutex(); f@0: f@0: //! Lock the mutex. f@0: void lock(void); f@0: f@0: //! Unlock the mutex. f@0: void unlock(void); f@0: f@0: //! Wait indefinitely on the mutex condition variable. f@0: /*! f@0: The mutex must be locked before calling this function, and then f@0: subsequently unlocked after this function returns. f@0: */ f@0: void wait(void); f@0: f@0: //! Signal the condition variable. f@0: /*! f@0: The mutex must be locked before calling this function, and then f@0: subsequently unlocked after this function returns. f@0: */ f@0: void signal(void); f@0: f@0: protected: f@0: f@0: MUTEX mutex_; f@0: CONDITION condition_; f@0: f@0: }; f@0: f@0: } // stk namespace f@0: f@0: #endif