|
||||
Warning, file /include/root/TSemaphore.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: Fons Rademakers 02/07/97 (Revised: G Ganis, Nov 2015) 0003 0004 /************************************************************************* 0005 * Copyright (C) 1995-2000, 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_TSemaphore 0013 #define ROOT_TSemaphore 0014 0015 ////////////////////////////////////////////////////////////////////////// 0016 // // 0017 // TSemaphore // 0018 // // 0019 // This class implements a counting semaphore. Use a semaphore // 0020 // to synchronize threads. // 0021 // // 0022 ////////////////////////////////////////////////////////////////////////// 0023 0024 #include <mutex> 0025 #include <condition_variable> 0026 0027 #include "TObject.h" 0028 0029 class TSemaphore : public TObject { 0030 0031 private: 0032 std::mutex fMutex; // semaphore mutex 0033 std::condition_variable fCond; // semaphore condition variable 0034 Int_t fValue; // semaphore value 0035 UInt_t fWakeups; // wakeups 0036 0037 TSemaphore(const TSemaphore &s) = delete; 0038 TSemaphore& operator=(const TSemaphore &s) = delete; 0039 0040 public: 0041 TSemaphore(Int_t initial = 1); 0042 virtual ~TSemaphore() { } 0043 0044 Int_t Wait(); 0045 Int_t Wait(Int_t millisec); 0046 Int_t TryWait(); 0047 Int_t Post(); 0048 0049 ClassDefOverride(TSemaphore, 0) // Counting semaphore 0050 }; 0051 0052 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |