CARMA C++
OneShotBarrier.h
1 #ifndef CARMA_UTIL_ONESHOTBARRIER_H
2 #define CARMA_UTIL_ONESHOTBARRIER_H
3 
4 #include "carma/util/PthreadCond.h"
5 #include "carma/util/PthreadMutex.h"
6 
7 
8 namespace carma {
9 namespace util {
10 
11 
12 class OneShotBarrier {
13  public:
14  explicit OneShotBarrier( size_t satisfyCount );
15 
16  virtual ~OneShotBarrier( );
17 
18  void wait( );
19 
20  private:
21  // No copying
22  OneShotBarrier( const OneShotBarrier & rhs );
23  OneShotBarrier & operator=( const OneShotBarrier & rhs );
24 
25  const size_t satisfyCount_;
26  PthreadMutex guard_;
27  PthreadCond satisfiedCond_;
28  size_t waitCount_;
29 };
30 
31 
32 } // namespace carma::util
33 } // namespace carma
34 
35 
36 #endif