// PThreadMutex.h #ifndef PThreadMutex_H #define PThreadMutex_H // Mutex class for use with POSIX threads. A thread is allowed to // lock the mutex any number of times and does not give up ownership // until it unlocks an equal number of times. #include class PThreadMutex { public: // Embedded classes. class Imp; private: // data Imp* pimp; private: // Hide copy and assignment. // Copy. PThreadMutex(const PThreadMutex& rhs); // Assignment. PThreadMutex& operator=(const PThreadMutex& rhs); public: // Constructor. PThreadMutex(); // Destructor. ~PThreadMutex(); // Lock. // Returns 0 for success. int lock(); // Unlock. // Returns 0 for success. int unlock(); // Return the bare mutex. #ifndef __CINT__ pthread_mutex_t& mutex(); #endif public: // const functions // Validity. bool is_valid() const; // Error status. // POSIX error code. int error() const; // Lock status. // Returns false if invalid. bool is_locked() const; // Unlock status. // Returns false if invalid. bool is_unlocked() const; // Owner. // Zero if unlocked. #ifndef __CINT__ pthread_t owner() const; #endif // Lock count. // Zero if unlocked. int lock_count() const; }; // Output stream. std::ostream& operator<<(std::ostream& lhs, const PThreadMutex& rhs); #endif