Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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&) = delete;
42 TCondition& operator=(const TCondition&) = delete;
43
44public:
45 TCondition(TMutex *m = nullptr);
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 ClassDefOverride(TCondition,0) // Condition variable class
57};
58
59#endif
unsigned long ULong_t
Definition RtypesCore.h:55
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
virtual Int_t Signal()=0
virtual Int_t Broadcast()=0
virtual ~TCondition()
Clean up condition variable.
Bool_t fPrivateMutex
Definition TCondition.h:39
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.
TCondition & operator=(const TCondition &)=delete
TConditionImp * fConditionImp
Definition TCondition.h:37
Int_t Signal()
Definition TCondition.h:53
Int_t TimedWaitRelative(ULong_t ms)
Wait to be signaled or till the timer times out.
TMutex * GetMutex() const
Get internally created mutex.
Int_t Wait()
Wait to be signaled.
TMutex * fMutex
Definition TCondition.h:38
TCondition(const TCondition &)=delete
Mother of all ROOT objects.
Definition TObject.h:41
<div class="legacybox"><h2>Legacy Code</h2> TThread is a legacy interface: there will be no bug fixes...
Definition TThread.h:40
TMarker m
Definition textangle.C:8