Logo ROOT  
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
TRWLock::ReadLock
Int_t ReadLock()
Obtain a reader lock. Returns always 0.
Definition: TRWLock.cxx:38
TCondition.h
TRWLock::WriteUnLock
Int_t WriteUnLock()
Unlock writer lock.
Definition: TRWLock.cxx:93
Int_t
int Int_t
Definition: RtypesCore.h:45
TRWLock::fLockFree
TCondition fLockFree
Definition: TRWLock.h:37
TRWLock::~TRWLock
virtual ~TRWLock()
Definition: TRWLock.h:44
TCondition
Definition: TCondition.h:32
TRWLock::fWriters
Int_t fWriters
Definition: TRWLock.h:35
TRWLock::fMutex
TMutex fMutex
Definition: TRWLock.h:36
TMutex.h
TRWLock::TRWLock
TRWLock()
Create reader/write lock.
Definition: TRWLock.cxx:29
TRWLock::fReaders
Int_t fReaders
Definition: TRWLock.h:34
TRWLock::ReadUnLock
Int_t ReadUnLock()
Unlock reader lock.
Definition: TRWLock.cxx:56
TRWLock
Definition: TRWLock.h:31
TRWLock::WriteLock
Int_t WriteLock()
Obtain a writer lock. Returns always 0.
Definition: TRWLock.cxx:75
TObject.h
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TMutex
Definition: TMutex.h:30
TRWLock::TRWLock
TRWLock(const TRWLock &)
TRWLock::operator=
TRWLock & operator=(const TRWLock &)
int