#ifndef __J2K__PThread_Mutex_HPP__ #define __J2K__PThread_Mutex_HPP__ #include // #include #undef MC_OnError #define MC_OnError( x, y, z ) if( x != 0 ){ printf( "An error occured [%d]\n", x ); } #include #include #include // Uses: // pthread_mutex_t // pthread_mutex_attr_t class PThread_Mutex { public: /****************************************************** ** Description of pthread_mutex_attr_t arguments. ** ** ** ** Attribute Default Value ** ** ========= ============= ** ** detachstate PTHREAD_CREATE_JOINABLE ** ** schedpolicy PTHREAD_INHERIT_SCHED ** ** schedparam Inherited from parent thread ** ** contentionscope PTHREAD_SCOPE_SYSTEM ** ** stacksize 4096 ** ** stackaddr NULL ** ******************************************************/ // Default Constructor PThread_Mutex(); // Destructor virtual ~PThread_Mutex(); // Lock the mutex void lock(); // Unlock the mutex void unlock(); // Try to lock a mutex inline void tryLock(); // Get the maximum priority (ceiling value) for the mutex inline int getPriorityCeiling(); // Set the maximum priority (ceiling value) for the mutex inline int setPriorityCeiling( int new_ceiling ); // Get the mutex attribute type inline int getType(); // Get the mutex attribute protocol inline int getProtocol(); inline void P() { lock(); } inline void V() { unlock(); } private: int mutex_type; int protocol; int prioceiling; int state; pid_t owner; pthread_mutexattr_t attr; pthread_mutex_t mutex; // Not implemented or needed. private: // Copy constructor inline PThread_Mutex( const PThread_Mutex& src ); // Assign operator inline const PThread_Mutex& operator=( const PThread_Mutex& src ); }; typedef PThread_Mutex Mutex; #include #endif