Logo ROOT   6.12/07
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 #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);
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
Definition: TMutex.h:30
auto * m
Definition: textangle.C:8
virtual ~TCondition()
Clean up condition variable.
Definition: TCondition.cxx:54
TMutex * fMutex
Definition: TCondition.h:38
Bool_t fPrivateMutex
Definition: TCondition.h:39
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:95
#define ClassDef(name, id)
Definition: Rtypes.h:320
TCondition & operator=(const TCondition &)
Int_t Broadcast()
Definition: TCondition.h:54
Int_t Wait()
Wait to be signaled.
Definition: TCondition.cxx:75
TConditionImp * fConditionImp
Definition: TCondition.h:37
TMutex * GetMutex() const
Get internally created mutex.
Definition: TCondition.cxx:65
static constexpr double ms
TCondition(const TCondition &)
unsigned long ULong_t
Definition: RtypesCore.h:51
Mother of all ROOT objects.
Definition: TObject.h:37
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:114
Int_t Signal()
Definition: TCondition.h:53