35 pthread_mutexattr_t attr;
37 rc = pthread_mutexattr_init(&attr);
40 rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
42 rc = pthread_mutex_init(&
fMutex, &attr);
44 SysError(
"TPosixMutex",
"pthread_mutex_init error");
46 SysError(
"TPosixMutex",
"pthread_mutexattr_settype error");
48 SysError(
"TPosixMutex",
"pthread_mutex_init error");
50 pthread_mutexattr_destroy(&attr);
54 int rc = pthread_mutex_init(&
fMutex, 0);
56 SysError(
"TPosixMutex",
"pthread_mutex_init error");
66 int rc = pthread_mutex_destroy(&
fMutex);
68 SysError(
"~TPosixMutex",
"pthread_mutex_destroy error");
76 return pthread_mutex_lock(&
fMutex);
84 return pthread_mutex_trylock(&
fMutex);
92 return pthread_mutex_unlock(&
fMutex);
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Int_t UnLock()
Unlock the mutex.
Int_t TryLock()
Try locking the mutex. Returns 0 if mutex can be locked.
static constexpr int kIsRecursive
TPosixMutex(Bool_t recursive=kFALSE)
Create a posix mutex lock.
Int_t Lock()
Lock the mutex.
virtual ~TPosixMutex()
TMutex dtor.