Logo ROOT   6.18/05
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
31class TRWLock : public TObject {
32
33private:
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
42public:
43 TRWLock();
44 virtual ~TRWLock() { }
45
50
51 ClassDef(TRWLock,0) // Reader/writer lock
52};
53
54#endif
int Int_t
Definition: RtypesCore.h:41
#define ClassDef(name, id)
Definition: Rtypes.h:326
Definition: TMutex.h:30
Mother of all ROOT objects.
Definition: TObject.h:37
TRWLock(const TRWLock &)
Int_t ReadLock()
Obtain a reader lock. Returns always 0.
Definition: TRWLock.cxx:38
TRWLock()
Create reader/write lock.
Definition: TRWLock.cxx:29
TMutex fMutex
Definition: TRWLock.h:36
Int_t WriteLock()
Obtain a writer lock. Returns always 0.
Definition: TRWLock.cxx:75
virtual ~TRWLock()
Definition: TRWLock.h:44
TRWLock & operator=(const TRWLock &)
Int_t WriteUnLock()
Unlock writer lock.
Definition: TRWLock.cxx:93
TCondition fLockFree
Definition: TRWLock.h:37
Int_t ReadUnLock()
Unlock reader lock.
Definition: TRWLock.cxx:56
Int_t fReaders
Definition: TRWLock.h:34
Int_t fWriters
Definition: TRWLock.h:35