TCondition.h

Go to the documentation of this file.
00001 // @(#)root/thread:$Id: TCondition.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Fons Rademakers   01/07/97
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TCondition
00013 #define ROOT_TCondition
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TCondition                                                           //
00019 //                                                                      //
00020 // This class implements a condition variable. Use a condition variable //
00021 // to signal threads. The actual work is done via the TConditionImp     //
00022 // class (either TPosixCondition or TWin32Condition).                   //
00023 //                                                                      //
00024 //////////////////////////////////////////////////////////////////////////
00025 
00026 #ifndef ROOT_TObject
00027 #include "TObject.h"
00028 #endif
00029 #ifndef ROOT_TConditionImp
00030 #include "TConditionImp.h"
00031 #endif
00032 
00033 class TMutex;
00034 
00035 
00036 class TCondition : public TObject {
00037 
00038 friend class TThread;
00039 
00040 private:
00041    TConditionImp  *fConditionImp;  // pointer to condition variable implementation
00042    TMutex         *fMutex;         // mutex used around Wait() and TimedWait()
00043    Bool_t          fPrivateMutex;  // is fMutex our private mutex
00044 
00045    TCondition(const TCondition&);             // not implemented
00046    TCondition& operator=(const TCondition&);  // not implemented
00047 
00048 public:
00049    TCondition(TMutex *m = 0);
00050    virtual ~TCondition();
00051 
00052    TMutex *GetMutex() const;
00053 
00054    Int_t   Wait();
00055    Int_t   TimedWait(ULong_t secs, ULong_t nanoSecs);
00056    Int_t   TimedWaitRelative(ULong_t ms);
00057    Int_t   Signal() { if (fConditionImp) return fConditionImp->Signal(); return -1; }
00058    Int_t   Broadcast() { if (fConditionImp) return fConditionImp->Broadcast(); return -1; }
00059 
00060    ClassDef(TCondition,0)  // Condition variable class
00061 };
00062 
00063 #endif

Generated on Tue Jul 5 14:11:59 2011 for ROOT_528-00b_version by  doxygen 1.5.1