ROOT logo
// @(#)root/thread:$Id: TRWLock.h 20882 2007-11-19 11:31:26Z rdm $
// Author: Fons Rademakers   04/01/2000

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TRWLock
#define ROOT_TRWLock


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TRWLock                                                              //
//                                                                      //
// This class implements a reader/writer lock. A rwlock allows          //
// a resource to be accessed by multiple reader threads but only        //
// one writer thread.                                                   //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_TMutex
#include "TMutex.h"
#endif
#ifndef ROOT_TCondition
#include "TCondition.h"
#endif


class TRWLock : public TObject {

private:
   Int_t        fReaders;   // number of readers
   Int_t        fWriters;   // number of writers
   TMutex       fMutex;     // rwlock mutex
   TCondition   fLockFree;  // rwlock condition variable

   TRWLock(const TRWLock &);           // not implemented
   TRWLock& operator=(const TRWLock&); // not implemented

public:
   TRWLock();
   virtual ~TRWLock() { }

   Int_t  ReadLock();
   Int_t  ReadUnLock();
   Int_t  WriteLock();
   Int_t  WriteUnLock();

   ClassDef(TRWLock,0)  // Reader/writer lock
};

#endif
 TRWLock.h:1
 TRWLock.h:2
 TRWLock.h:3
 TRWLock.h:4
 TRWLock.h:5
 TRWLock.h:6
 TRWLock.h:7
 TRWLock.h:8
 TRWLock.h:9
 TRWLock.h:10
 TRWLock.h:11
 TRWLock.h:12
 TRWLock.h:13
 TRWLock.h:14
 TRWLock.h:15
 TRWLock.h:16
 TRWLock.h:17
 TRWLock.h:18
 TRWLock.h:19
 TRWLock.h:20
 TRWLock.h:21
 TRWLock.h:22
 TRWLock.h:23
 TRWLock.h:24
 TRWLock.h:25
 TRWLock.h:26
 TRWLock.h:27
 TRWLock.h:28
 TRWLock.h:29
 TRWLock.h:30
 TRWLock.h:31
 TRWLock.h:32
 TRWLock.h:33
 TRWLock.h:34
 TRWLock.h:35
 TRWLock.h:36
 TRWLock.h:37
 TRWLock.h:38
 TRWLock.h:39
 TRWLock.h:40
 TRWLock.h:41
 TRWLock.h:42
 TRWLock.h:43
 TRWLock.h:44
 TRWLock.h:45
 TRWLock.h:46
 TRWLock.h:47
 TRWLock.h:48
 TRWLock.h:49
 TRWLock.h:50
 TRWLock.h:51
 TRWLock.h:52
 TRWLock.h:53
 TRWLock.h:54
 TRWLock.h:55
 TRWLock.h:56
 TRWLock.h:57
 TRWLock.h:58
 TRWLock.h:59
 TRWLock.h:60