Logo ROOT   6.16/01
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
29class TMutex;
30
31
32class TCondition : public TObject {
33
34friend class TThread;
35
36private:
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
44public:
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
int Int_t
Definition: RtypesCore.h:41
unsigned long ULong_t
Definition: RtypesCore.h:51
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:324
virtual Int_t Signal()=0
virtual Int_t Broadcast()=0
virtual ~TCondition()
Clean up condition variable.
Definition: TCondition.cxx:54
Bool_t fPrivateMutex
Definition: TCondition.h:39
TCondition & operator=(const TCondition &)
Int_t Broadcast()
Definition: TCondition.h:54
Int_t TimedWait(ULong_t secs, ULong_t nanoSecs)
Wait to be signaled or till the timer times out.
Definition: TCondition.cxx:95
TConditionImp * fConditionImp
Definition: TCondition.h:37
Int_t Signal()
Definition: TCondition.h:53
TCondition(const TCondition &)
Int_t TimedWaitRelative(ULong_t ms)
Wait to be signaled or till the timer times out.
Definition: TCondition.cxx:114
TMutex * GetMutex() const
Get internally created mutex.
Definition: TCondition.cxx:65
Int_t Wait()
Wait to be signaled.
Definition: TCondition.cxx:75
TMutex * fMutex
Definition: TCondition.h:38
Definition: TMutex.h:30
Mother of all ROOT objects.
Definition: TObject.h:37
static constexpr double ms
auto * m
Definition: textangle.C:8