OSSIM - Open Source Software Image Map
Version 1.9.0 (20180803)
|
Barrier is a class used to block threads so we can synchronize and entry point. More...
#include <Barrier.h>
Public Member Functions | |
Barrier (ossim_int32 n) | |
Constructor. More... | |
~Barrier () | |
Destructor will reset and release all blocked threads. More... | |
void | block () |
block will block the thread based on a wait condition. More... | |
void | reset () |
Will reset the barrier to the original values. More... | |
void | reset (ossim_int32 maxCount) |
Will reset the barrier to a new block count. More... | |
ossim_int32 | getMaxCount () const |
ossim_int32 | getBlockedCount () const |
Protected Attributes | |
ossim_int32 | m_maxCount |
ossim_int32 | m_blockedCount |
std::atomic< ossim_int32 > | m_waitCount |
std::mutex | m_mutex |
std::condition_variable | m_conditionalBlock |
std::condition_variable | m_conditionalWait |
Will be used for destructing and resetting. More... | |
Barrier is a class used to block threads so we can synchronize and entry point.
In this example we show how to block the threads so they all start at the same time when executing their work. Example:
ossim::Barrier::Barrier | ( | ossim_int32 | n | ) |
Constructor.
n | is the number of threads you wish to block |
Definition at line 3 of file Barrier.cpp.
ossim::Barrier::~Barrier | ( | ) |
Destructor will reset and release all blocked threads.
Definition at line 11 of file Barrier.cpp.
void ossim::Barrier::block | ( | ) |
block will block the thread based on a wait condition.
it will verify if the thread can be blocked by testing if the number of blocked threads is less than the total number to blocked threads. If the total is reached then all threads are notified and woken up and released
Definition at line 16 of file Barrier.cpp.
ossim_int32 ossim::Barrier::getBlockedCount | ( | ) | const |
Definition at line 66 of file Barrier.cpp.
ossim_int32 ossim::Barrier::getMaxCount | ( | ) | const |
Definition at line 60 of file Barrier.cpp.
void ossim::Barrier::reset | ( | ) |
Will reset the barrier to the original values.
It will also release all blocked threads and wait for their release before resetting.
Definition at line 34 of file Barrier.cpp.
void ossim::Barrier::reset | ( | ossim_int32 | maxCount | ) |
Will reset the barrier to a new block count.
It will also release all blocked threads and wait for their release before resetting.
maxCount | is the max number of threads to block |
Definition at line 49 of file Barrier.cpp.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |