ML Reference
|
A helper class that ensures barrier waiting even when an exception occurs. More...
#include <mlBarrier.h>
Public Member Functions | |
ScopedBarrierWaiter (Barrier &barrier, unsigned int numberOfExpectedWaits=1) | |
Creates a ScopedBarrierWaiter that ensures that the barrier gets numberOfExpectedWaits calls to Barrier::wait(). | |
~ScopedBarrierWaiter () | |
void | wait () |
Waits for the barrier (this will prevent the ScopedBarrierWaiter from waiting in its destructor). | |
A helper class that ensures barrier waiting even when an exception occurs.
The rationale of this class is that typically a barrier will not be waited on when an exception occurs and this will cause other threads to wait forever. By calling Barrier::wait() in the destructor (if it was not called manually beforehand), the ScopedBarrierWaiter ensures that the barrier is waited for. Make sure that you use any instance of this object only from within the same thread. You should also avoid calling Barrier::wait() on a barrier that you have passed to a ScopedBarrierWaiter from within the same thread.
Definition at line 79 of file mlBarrier.h.
ml::ScopedBarrierWaiter::ScopedBarrierWaiter | ( | Barrier & | barrier, |
unsigned int | numberOfExpectedWaits = 1 ) |
Creates a ScopedBarrierWaiter that ensures that the barrier gets numberOfExpectedWaits
calls to Barrier::wait().
ml::ScopedBarrierWaiter::~ScopedBarrierWaiter | ( | ) |
void ml::ScopedBarrierWaiter::wait | ( | ) |
Waits for the barrier (this will prevent the ScopedBarrierWaiter from waiting in its destructor).