ROOT  6.06/09
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 #ifndef ROOT_TConditionImp
26 #include "TConditionImp.h"
27 #endif
28 
29 #include "Windows4Root.h"
30 
31 #ifndef __CINT__
32 typedef struct
33 {
35  // Number of waiting threads.
36 
37  CRITICAL_SECTION waiters_count_lock_;
38  // Serialize access to <waiters_count_>.
39 
40  HANDLE sema_;
41  // Semaphore used to queue up threads waiting for the condition to
42  // become signaled.
43 
44  HANDLE waiters_done_;
45  // An auto-reset event used by the broadcast/signal thread to wait
46  // for all the waiting thread(s) to wake up and be released from the
47  // semaphore.
48 
50  // Keeps track of whether we were broadcasting or signaling. This
51  // allows us to optimize the code if we're just signaling.
53 #else
54 struct pthread_cond_t;
55 #endif
56 
57 class TMutexImp;
58 class TWin32Mutex;
59 
60 
62 
63 private:
64  pthread_cond_t fCond; // the pthread condition variable
65  TWin32Mutex *fMutex; // mutex used around Wait() and TimedWait()
66 
67 public:
69  virtual ~TWin32Condition();
70 
71  Int_t Wait();
72  Int_t TimedWait(ULong_t secs, ULong_t nanoSecs = 0);
73  Int_t Signal();
74  Int_t Broadcast();
75 
76  ClassDef(TWin32Condition,0) // Posix condition variable
77 };
78 
79 #endif
Int_t TimedWait(ULong_t secs, ULong_t nanoSecs=0)
TimedWait() is given an absolute time to wait until.
Int_t Wait()
Wait for the condition variable to be signalled.
int Int_t
Definition: RtypesCore.h:41
#define ClassDef(name, id)
Definition: Rtypes.h:254
pthread_cond_t fCond
TWin32Condition(TMutexImp *m)
TMarker * m
Definition: textangle.C:8
virtual ~TWin32Condition()
TCondition dtor.
Int_t Signal()
If one or more threads have called Wait(), Signal() wakes up at least one of them, possibly more.
unsigned long ULong_t
Definition: RtypesCore.h:51
TWin32Mutex * fMutex
Int_t Broadcast()
Broadcast is like signal but wakes all threads which have called Wait().
CRITICAL_SECTION waiters_count_lock_