Logo ROOT   6.10/09
Reference Guide
TRWLock.h
Go to the documentation of this file.
1 // @(#)root/thread:$Id$
2 // Author: Fons Rademakers 04/01/2000
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 #ifndef ROOT_TRWLock
13 #define ROOT_TRWLock
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TRWLock //
19 // //
20 // This class implements a reader/writer lock. A rwlock allows //
21 // a resource to be accessed by multiple reader threads but only //
22 // one writer thread. //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 #include "TObject.h"
27 #include "TMutex.h"
28 #include "TCondition.h"
29 
30 
31 class TRWLock : public TObject {
32 
33 private:
34  Int_t fReaders; // number of readers
35  Int_t fWriters; // number of writers
36  TMutex fMutex; // rwlock mutex
37  TCondition fLockFree; // rwlock condition variable
38 
39  TRWLock(const TRWLock &); // not implemented
40  TRWLock& operator=(const TRWLock&); // not implemented
41 
42 public:
43  TRWLock();
44  virtual ~TRWLock() { }
45 
46  Int_t ReadLock();
47  Int_t ReadUnLock();
48  Int_t WriteLock();
50 
51  ClassDef(TRWLock,0) // Reader/writer lock
52 };
53 
54 #endif
Int_t WriteUnLock()
Unlock writer lock.
Definition: TRWLock.cxx:93
Int_t WriteLock()
Obtain a writer lock. Returns always 0.
Definition: TRWLock.cxx:75
Definition: TMutex.h:30
Int_t ReadLock()
Obtain a reader lock. Returns always 0.
Definition: TRWLock.cxx:38
virtual ~TRWLock()
Definition: TRWLock.h:44
Int_t fReaders
Definition: TRWLock.h:34
int Int_t
Definition: RtypesCore.h:41
#define ClassDef(name, id)
Definition: Rtypes.h:297
Int_t fWriters
Definition: TRWLock.h:35
TMutex fMutex
Definition: TRWLock.h:36
TCondition fLockFree
Definition: TRWLock.h:37
TRWLock & operator=(const TRWLock &)
Mother of all ROOT objects.
Definition: TObject.h:37
TRWLock()
Create reader/write lock.
Definition: TRWLock.cxx:29
Int_t ReadUnLock()
Unlock reader lock.
Definition: TRWLock.cxx:56