ROOT  6.06/09
Reference Guide
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 #ifndef ROOT_TObject
27 #include "TObject.h"
28 #endif
29 #ifndef ROOT_TConditionImp
30 #include "TConditionImp.h"
31 #endif
32 
33 class TMutex;
34 
35 
36 class TCondition : public TObject {
37 
38 friend class TThread;
39 
40 private:
41  TConditionImp *fConditionImp; // pointer to condition variable implementation
42  TMutex *fMutex; // mutex used around Wait() and TimedWait()
43  Bool_t fPrivateMutex; // is fMutex our private mutex
44 
45  TCondition(const TCondition&); // not implemented
46  TCondition& operator=(const TCondition&); // not implemented
47 
48 public:
49  TCondition(TMutex *m = 0);
50  virtual ~TCondition();
51 
52  TMutex *GetMutex() const;
53 
54  Int_t Wait();
55  Int_t TimedWait(ULong_t secs, ULong_t nanoSecs);
57  Int_t Signal() { if (fConditionImp) return fConditionImp->Signal(); return -1; }
58  Int_t Broadcast() { if (fConditionImp) return fConditionImp->Broadcast(); return -1; }
59 
60  ClassDef(TCondition,0) // Condition variable class
61 };
62 
63 #endif
Definition: TMutex.h:37
virtual ~TCondition()
Clean up condition variable.
Definition: TCondition.cxx:53
TMutex * fMutex
Definition: TCondition.h:42
Bool_t fPrivateMutex
Definition: TCondition.h:43
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t TimedWait(ULong_t secs, ULong_t nanoSecs)
Wait to be signaled or till the timer times out.
Definition: TCondition.cxx:94
#define ClassDef(name, id)
Definition: Rtypes.h:254
TCondition & operator=(const TCondition &)
Int_t Broadcast()
Definition: TCondition.h:58
Int_t Wait()
Wait to be signaled.
Definition: TCondition.cxx:74
TMutex * GetMutex() const
Get internally created mutex.
Definition: TCondition.cxx:64
TConditionImp * fConditionImp
Definition: TCondition.h:41
TMarker * m
Definition: textangle.C:8
TCondition(const TCondition &)
unsigned long ULong_t
Definition: RtypesCore.h:51
Mother of all ROOT objects.
Definition: TObject.h:58
virtual Int_t Signal()=0
virtual Int_t Broadcast()=0
Int_t TimedWaitRelative(ULong_t ms)
Wait to be signaled or till the timer times out.
Definition: TCondition.cxx:113
Int_t Signal()
Definition: TCondition.h:57