Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TWin32Condition.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/thread:$Id$
0002 // Author: Bertrand Bellenot  20/10/2004
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TWin32Condition
0013 #define ROOT_TWin32Condition
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TWin32Condition                                                      //
0019 //                                                                      //
0020 // This class provides an interface to the win32 condition variable     //
0021 // routines.                                                            //
0022 //                                                                      //
0023 //////////////////////////////////////////////////////////////////////////
0024 
0025 #include "TConditionImp.h"
0026 
0027 #include "Windows4Root.h"
0028 
0029 typedef struct
0030 {
0031    int waiters_count_;
0032    // Number of waiting threads.
0033 
0034    CRITICAL_SECTION waiters_count_lock_;
0035    // Serialize access to <waiters_count_>.
0036 
0037    HANDLE sema_;
0038    // Semaphore used to queue up threads waiting for the condition to
0039    // become signaled.
0040 
0041    HANDLE waiters_done_;
0042    // An auto-reset event used by the broadcast/signal thread to wait
0043    // for all the waiting thread(s) to wake up and be released from the
0044    // semaphore.
0045 
0046    size_t was_broadcast_;
0047    // Keeps track of whether we were broadcasting or signaling.  This
0048    // allows us to optimize the code if we're just signaling.
0049 } pthread_cond_t;
0050 
0051 class TMutexImp;
0052 class TWin32Mutex;
0053 
0054 
0055 class TWin32Condition : public TConditionImp {
0056 
0057 private:
0058    pthread_cond_t  fCond;    // the pthread condition variable
0059    TWin32Mutex    *fMutex;   // mutex used around Wait() and TimedWait()
0060 
0061 public:
0062    TWin32Condition(TMutexImp *m);
0063    virtual ~TWin32Condition();
0064 
0065    Int_t  Wait() override;
0066    Int_t  TimedWait(ULong_t secs, ULong_t nanoSecs = 0) override;
0067    Int_t  Signal() override;
0068    Int_t  Broadcast() override;
0069 
0070    ClassDefOverride(TWin32Condition,0)   // Posix condition variable
0071 };
0072 
0073 #endif