34 pthread_mutexattr_t attr;
36 rc = pthread_mutexattr_init(&attr);
39 rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
41 rc = pthread_mutex_init(&
fMutex, &attr);
43 SysError(
"TPosixMutex",
"pthread_mutex_init error");
45 SysError(
"TPosixMutex",
"pthread_mutexattr_settype error");
47 SysError(
"TPosixMutex",
"pthread_mutex_init error");
49 pthread_mutexattr_destroy(&attr);
53 int rc = pthread_mutex_init(&
fMutex,
nullptr);
55 SysError(
"TPosixMutex",
"pthread_mutex_init error");
65 int rc = pthread_mutex_destroy(&
fMutex);
67 SysError(
"~TPosixMutex",
"pthread_mutex_destroy error");
75 return pthread_mutex_lock(&
fMutex);
83 return pthread_mutex_trylock(&
fMutex);
91 return pthread_mutex_unlock(&
fMutex);
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
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() override
Unlock the mutex.
static constexpr int kIsRecursive
TPosixMutex(Bool_t recursive=kFALSE)
Create a posix mutex lock.
Int_t Lock() override
Lock the mutex.
Int_t TryLock() override
Try locking the mutex. Returns 0 if mutex can be locked.
virtual ~TPosixMutex()
TMutex dtor.