/* * MutexedClass.hh * * Created on: Feb 15, 2015 * Author: Hovanes Egiyan */ #ifndef _MUTEXEDCLASS_HH_ #define _MUTEXEDCLASS_HH_ extern "C" { #include } ; class MutexedClass { protected: pthread_mutex_t mcMutex; //! Mutex for an object pthread_mutexattr_t mcMtxAttr; //! Mutex attributes for an object static pthread_mutex_t mcClassMutex; //! Class for this class static pthread_mutexattr_t mcClassMtxAttr; //! Class mutex attributes //! Initialize the mutex for the object void initMutex(); //! Destroy the mutex for the object void closeMutex(); //! Lock the class mutex for this class inline static int classLock() { return pthread_mutex_lock(&mcClassMutex); } //! Unlock the class mutex for this class inline static int classUnlock() { return pthread_mutex_unlock(&mcClassMutex); } public: MutexedClass(); virtual ~MutexedClass(); //! Initialize global mutex static int initGlobalMutex(); }; #endif /* _MUTEXEDCLASS_HH_ */