MeVisLab Toolbox Reference
ml::ScopedBarrierWaiter Class 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(). More...
 
 ~ScopedBarrierWaiter ()
 
void wait ()
 Waits for the barrier (this will prevent the ScopedBarrierWaiter from waiting in its destructor). More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ScopedBarrierWaiter()

ml::ScopedBarrierWaiter::ScopedBarrierWaiter ( Barrier barrier,
unsigned int  numberOfExpectedWaits = 1 
)

Creates a ScopedBarrierWaiter that ensures that the barrier gets numberOfExpectedWaits calls to Barrier::wait().

◆ ~ScopedBarrierWaiter()

ml::ScopedBarrierWaiter::~ScopedBarrierWaiter ( )

Member Function Documentation

◆ wait()

void ml::ScopedBarrierWaiter::wait ( )

Waits for the barrier (this will prevent the ScopedBarrierWaiter from waiting in its destructor).


The documentation for this class was generated from the following file: