CountBarrier.h 411 B

1234567891011121314151617181920212223242526272829
  1. #ifndef THREAD_COUNT_LATCH_H
  2. #define THREAD_COUNT_LATCH_H
  3. #include <boost/thread.hpp>
  4. namespace Egametang {
  5. class CountBarrier
  6. {
  7. private:
  8. int count;
  9. mutable boost::mutex mutex;
  10. boost::condition_variable condition;
  11. public:
  12. explicit CountBarrier(int count = 1);
  13. void Wait();
  14. void Signal();
  15. int Count() const;
  16. void Reset(int count = 1);
  17. };
  18. } // namespace Egametang
  19. #endif // THREAD_COUNT_LATCH_H