Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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();
49  Int_t WriteUnLock();
50 
51  ClassDef(TRWLock,0) // Reader/writer lock
52 };
53 
54 #endif