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
25
26////////////////////////////////////////////////////////////////////////////////
27/// Create a posix mutex lock.
28
30{
31 if (recursive) {
33
34 int rc;
36
38
39 if (!rc) {
41 if (!rc) {
43 if (rc)
44 SysError("TPosixMutex", "pthread_mutex_init error");
45 } else
46 SysError("TPosixMutex", "pthread_mutexattr_settype error");
47 } else
48 SysError("TPosixMutex", "pthread_mutex_init error");
49
51
52 } else {
53
54 int rc = pthread_mutex_init(&fMutex, 0);
55 if (rc)
56 SysError("TPosixMutex", "pthread_mutex_init error");
57
58 }
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// TMutex dtor.
63
65{
67 if (rc)
68 SysError("~TPosixMutex", "pthread_mutex_destroy error");
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Lock the mutex.
73
78
79////////////////////////////////////////////////////////////////////////////////
80/// Try locking the mutex. Returns 0 if mutex can be locked.
81
86
87////////////////////////////////////////////////////////////////////////////////
88/// Unlock the mutex.
89
#define ClassImp(name)
Definition Rtypes.h:374
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:1068
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:847
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.