Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPosixMutex.cxx
Go to the documentation of this file.
1// @(#)root/thread:$Id$
2// Author: Fons Rademakers 25/06/97
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12//////////////////////////////////////////////////////////////////////////
13// //
14// TPosixMutex //
15// //
16// This class provides an interface to the posix mutex routines. //
17// //
18//////////////////////////////////////////////////////////////////////////
19
20#include "TThread.h"
21#include "TPosixMutex.h"
22#include "PosixThreadInc.h"
23
24
25////////////////////////////////////////////////////////////////////////////////
26/// Create a posix mutex lock.
27
29{
30 if (recursive) {
32
33 int rc;
35
37
38 if (!rc) {
40 if (!rc) {
42 if (rc)
43 SysError("TPosixMutex", "pthread_mutex_init error");
44 } else
45 SysError("TPosixMutex", "pthread_mutexattr_settype error");
46 } else
47 SysError("TPosixMutex", "pthread_mutex_init error");
48
50
51 } else {
52
53 int rc = pthread_mutex_init(&fMutex, nullptr);
54 if (rc)
55 SysError("TPosixMutex", "pthread_mutex_init error");
56
57 }
58}
59
60////////////////////////////////////////////////////////////////////////////////
61/// TMutex dtor.
62
64{
66 if (rc)
67 SysError("~TPosixMutex", "pthread_mutex_destroy error");
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// Lock the mutex.
72
77
78////////////////////////////////////////////////////////////////////////////////
79/// Try locking the mutex. Returns 0 if mutex can be locked.
80
85
86////////////////////////////////////////////////////////////////////////////////
87/// Unlock the mutex.
88
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Definition TObject.cxx:1085
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:864
pthread_mutex_t fMutex
Definition TPosixMutex.h:33
Int_t UnLock() override
Unlock the mutex.
static constexpr int kIsRecursive
Definition TPosixMutex.h:35
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.