Logo ROOT   6.16/01
Reference Guide
TWin32Condition.h
Go to the documentation of this file.
1// @(#)root/thread:$Id$
2// Author: Bertrand Bellenot 20/10/2004
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, 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_TWin32Condition
13#define ROOT_TWin32Condition
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TWin32Condition //
19// //
20// This class provides an interface to the win32 condition variable //
21// routines. //
22// //
23//////////////////////////////////////////////////////////////////////////
24
25#include "TConditionImp.h"
26
27#include "Windows4Root.h"
28
29#ifndef __CINT__
30typedef struct
31{
33 // Number of waiting threads.
34
35 CRITICAL_SECTION waiters_count_lock_;
36 // Serialize access to <waiters_count_>.
37
38 HANDLE sema_;
39 // Semaphore used to queue up threads waiting for the condition to
40 // become signaled.
41
43 // An auto-reset event used by the broadcast/signal thread to wait
44 // for all the waiting thread(s) to wake up and be released from the
45 // semaphore.
46
48 // Keeps track of whether we were broadcasting or signaling. This
49 // allows us to optimize the code if we're just signaling.
51#else
52struct pthread_cond_t;
53#endif
54
55class TMutexImp;
56class TWin32Mutex;
57
58
60
61private:
62 pthread_cond_t fCond; // the pthread condition variable
63 TWin32Mutex *fMutex; // mutex used around Wait() and TimedWait()
64
65public:
67 virtual ~TWin32Condition();
68
69 Int_t Wait();
70 Int_t TimedWait(ULong_t secs, ULong_t nanoSecs = 0);
71 Int_t Signal();
73
74 ClassDef(TWin32Condition,0) // Posix condition variable
75};
76
77#endif
int Int_t
Definition: RtypesCore.h:41
unsigned long ULong_t
Definition: RtypesCore.h:51
#define ClassDef(name, id)
Definition: Rtypes.h:324
Int_t Wait()
Wait for the condition variable to be signalled.
pthread_cond_t fCond
virtual ~TWin32Condition()
TCondition dtor.
Int_t Broadcast()
Broadcast is like signal but wakes all threads which have called Wait().
TWin32Condition(TMutexImp *m)
Create Condition variable.
TWin32Mutex * fMutex
Int_t TimedWait(ULong_t secs, ULong_t nanoSecs=0)
TimedWait() is given an absolute time to wait until.
Int_t Signal()
If one or more threads have called Wait(), Signal() wakes up at least one of them,...
CRITICAL_SECTION waiters_count_lock_
auto * m
Definition: textangle.C:8