ML Reference
mlBarrier.h
Go to the documentation of this file.
1
/*************************************************************************************
2
**
3
** Copyright 2009, MeVis Medical Solutions AG
4
**
5
** The user may use this file in accordance with the license agreement provided with
6
** the Software or, alternatively, in accordance with the terms contained in a
7
** written agreement between the user and MeVis Medical Solutions AG.
8
**
9
** For further information use the contact form at https://www.mevislab.de/contact
10
**
11
**************************************************************************************/
12
13
#ifndef ML_BARRIER_H
14
#define ML_BARRIER_H
15
18
19
#include "
mlUtilsSystem.h
"
20
21
#include "
mlMutex.h
"
22
#include "
mlWaitCondition.h
"
23
24
ML_UTILS_START_NAMESPACE
25
26
//----------------------------------------------------------------------------------
30
//----------------------------------------------------------------------------------
31
class
ML_UTILS_EXPORT
Barrier
{
32
33
public
:
34
//----------------------------------------------------------------------------------
36
//----------------------------------------------------------------------------------
37
Barrier
(
unsigned
int
count = 0);
38
39
//----------------------------------------------------------------------------------
42
//----------------------------------------------------------------------------------
43
void
setNumberOfThreads
(
unsigned
int
count);
44
45
//----------------------------------------------------------------------------------
48
//----------------------------------------------------------------------------------
49
bool
wait
();
50
51
private
:
53
Barrier
(
const
Barrier
&);
54
Barrier
& operator =(
const
Barrier
&);
55
57
unsigned
int
_count;
59
unsigned
int
_generation;
61
unsigned
int
_numberOfThreads;
62
64
Mutex
_mutex;
66
WaitCondition
_finishedNotifier;
67
};
68
69
//----------------------------------------------------------------------------------
78
//----------------------------------------------------------------------------------
79
class
ML_UTILS_EXPORT
ScopedBarrierWaiter
{
80
81
public
:
82
//----------------------------------------------------------------------------------
85
//----------------------------------------------------------------------------------
86
ScopedBarrierWaiter
(
Barrier
& barrier,
unsigned
int
numberOfExpectedWaits = 1);
87
~ScopedBarrierWaiter
();
88
89
//----------------------------------------------------------------------------------
92
//----------------------------------------------------------------------------------
93
void
wait
();
94
95
private
:
97
ScopedBarrierWaiter
(
const
ScopedBarrierWaiter
&);
98
ScopedBarrierWaiter
& operator =(
const
ScopedBarrierWaiter
&);
99
101
Barrier
& _barrier;
103
unsigned
int
_numberOfExpectedWaits;
104
};
105
106
ML_UTILS_END_NAMESPACE
107
108
#endif
// __mlBarrier_H
109
110
ml::Barrier
Definition
mlBarrier.h:31
ml::Barrier::Barrier
Barrier(unsigned int count=0)
Creates a barrier with initial count of threads to synchronize.
ml::Barrier::wait
bool wait()
ml::Barrier::setNumberOfThreads
void setNumberOfThreads(unsigned int count)
ml::ScopedBarrierWaiter::~ScopedBarrierWaiter
~ScopedBarrierWaiter()
ml::ScopedBarrierWaiter::ScopedBarrierWaiter
ScopedBarrierWaiter(Barrier &barrier, unsigned int numberOfExpectedWaits=1)
ml::ScopedBarrierWaiter::wait
void wait()
ml::WaitCondition
Definition
mlWaitCondition.h:46
ml::Mutex
boost::mutex Mutex
Definition
mlMutex.h:39
mlMutex.h
ML_UTILS_EXPORT
#define ML_UTILS_EXPORT
Definition
mlUtilities.h:18
mlUtilsSystem.h
mlWaitCondition.h
MeVis
Foundation
Sources
MLUtilities
mlBarrier.h
Generated by
1.15.0