Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TCondition.h
Go to the documentation of this file.
1 // @(#)root/thread:$Id$
2 // Author: Fons Rademakers 01/07/97
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_TCondition
13 #define ROOT_TCondition
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TCondition //
19 // //
20 // This class implements a condition variable. Use a condition variable //
21 // to signal threads. The actual work is done via the TConditionImp //
22 // class (either TPosixCondition or TWin32Condition). //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 #include "TObject.h"
27 #include "TConditionImp.h"
28 
29 class TMutex;
30 
31 
32 class TCondition : public TObject {
33 
34 friend class TThread;
35 
36 private:
37  TConditionImp *fConditionImp; // pointer to condition variable implementation
38  TMutex *fMutex; // mutex used around Wait() and TimedWait()
39  Bool_t fPrivateMutex; // is fMutex our private mutex
40 
41  TCondition(const TCondition&); // not implemented
42  TCondition& operator=(const TCondition&); // not implemented
43 
44 public:
45  TCondition(TMutex *m = 0);
46  virtual ~TCondition();
47 
48  TMutex *GetMutex() const;
49 
50  Int_t Wait();
51  Int_t TimedWait(ULong_t secs, ULong_t nanoSecs);
52  Int_t TimedWaitRelative(ULong_t ms);
53  Int_t Signal() { if (fConditionImp) return fConditionImp->Signal(); return -1; }
54  Int_t Broadcast() { if (fConditionImp) return fConditionImp->Broadcast(); return -1; }
55 
56  ClassDef(TCondition,0) // Condition variable class
57 };
58 
59 #endif