OSSIM - Open Source Software Image Map
Version 1.9.0 (20180803)
|
This is a very simple block interface. More...
#include <Block.h>
Public Member Functions | |
Block (bool releaseFlag=false) | |
Allows one the construct a Block with a release state. More... | |
~Block () | |
Destructor. More... | |
void | set (bool releaseFlag) |
Will set the relase flag and wake up all threads to test the condition again. More... | |
void | block () |
Will block the calling thread based on the internal condition. More... | |
void | block (ossim_uint64 waitTimeMillis) |
Will block the calling thread base on the internal condition. More... | |
void | release () |
Releases the threads and will not return until all threads are released. More... | |
void | reset () |
Simple reset the values. More... | |
Private Attributes | |
std::mutex | m_mutex |
Used by the conditions. More... | |
std::atomic< bool > | m_release |
The release state. More... | |
std::condition_variable | m_conditionVariable |
Condition that tests the release state. More... | |
std::atomic< ossim_int32 > | m_waitCount |
Used to count the number of threads blocked or waiting on the condition. More... | |
std::condition_variable | m_conditionalWait |
Will be used for destructing and releasing. More... | |
This is a very simple block interface.
This allows one to control how their threads are blocked
There is a release state flag that tells the call to block to block the calling thread or release the thread(s) that are currently blocked
For a very simple use case we will start a thread and call block and have the main sleep for 2 seconds before releasing the thread
ossim::Block::Block | ( | bool | releaseFlag = false | ) |
Allows one the construct a Block with a release state.
Definition at line 4 of file Block.cpp.
ossim::Block::~Block | ( | ) |
Destructor.
Will set internally call release
Definition at line 11 of file Block.cpp.
void ossim::Block::block | ( | ) |
Will block the calling thread based on the internal condition.
If the internal condition is set to release then it will return without blocking.
Definition at line 33 of file Block.cpp.
Referenced by ossimMultiThreadSequencer::getNextTile(), ossimMultiThreadSequencer::nextJob(), and ossimJobQueue::nextJob().
void ossim::Block::block | ( | ossim_uint64 | waitTimeMillis | ) |
Will block the calling thread base on the internal condition.
If the internal condition is set to release the it will return without blocking. If the internal condition is set to not release then it will block for the specified time in milliseconds
waitTimeMillis | specifies the amount of time to wait for the release |
Definition at line 49 of file Block.cpp.
void ossim::Block::release | ( | ) |
Releases the threads and will not return until all threads are released.
Definition at line 66 of file Block.cpp.
Referenced by ossimMultiThreadSequencer::getNextTile(), ossimJobQueue::releaseBlock(), and ossimMultiThreadSequencer::ossimGetTileJob::run().
void ossim::Block::reset | ( | ) |
Simple reset the values.
Will not do any releasing
Definition at line 78 of file Block.cpp.
Referenced by ossimMultiThreadSequencer::getNextTile(), and ossimMultiThreadSequencer::nextJob().
void ossim::Block::set | ( | bool | releaseFlag | ) |
Will set the relase flag and wake up all threads to test the condition again.
Definition at line 23 of file Block.cpp.
Referenced by ossimJobQueue::add(), ossimJobQueue::nextJob(), ossimJobQueue::removeById(), and ossimJobQueue::removeByName().
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |