OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Block.h
Go to the documentation of this file.
1 #ifndef ossimBlock_HEADER
2 #define ossimBlock_HEADER 1
4 #include <mutex>
5 #include <condition_variable>
6 #include <atomic>
7 
8 namespace ossim{
9 
46  {
47  public:
51  Block(bool releaseFlag=false);
52 
58  ~Block();
59 
63  void set(bool releaseFlag);
64 
69  void block();
70 
79  void block(ossim_uint64 waitTimeMillis);
80 
84  void release();
85 
89  void reset();
90 
91  private:
95  mutable std::mutex m_mutex;
96 
100  std::atomic<bool> m_release;
101 
105  std::condition_variable m_conditionVariable;
106 
111  std::atomic<ossim_int32> m_waitCount;
112 
118  std::condition_variable m_conditionalWait;
119  };
120 }
121 #endif
std::atomic< bool > m_release
The release state.
Definition: Block.h:100
std::condition_variable m_conditionVariable
Condition that tests the release state.
Definition: Block.h:105
std::atomic< ossim_int32 > m_waitCount
Used to count the number of threads blocked or waiting on the condition.
Definition: Block.h:111
std::mutex m_mutex
Used by the conditions.
Definition: Block.h:95
This code was derived from https://gist.github.com/mshockwave.
Definition: Barrier.h:8
unsigned long long ossim_uint64
This is a very simple block interface.
Definition: Block.h:45
std::condition_variable m_conditionalWait
Will be used for destructing and releasing.
Definition: Block.h:118
#define OSSIM_DLL