TDME2
1.9.200
src
tdme
os
threading
Barrier.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
tdme/os/threading/fwd-tdme.h
>
4
5
#include <
tdme/tdme.h
>
6
7
#include <string>
8
9
#include <
tdme/os/threading/Condition.h
>
10
#include <
tdme/os/threading/Mutex.h
>
11
12
using
std::string;
13
14
using
tdme::os::threading::Condition
;
15
using
tdme::os::threading::Mutex
;
16
17
/**
18
* Barrier implementation.
19
* @author Andreas Drewke
20
*/
21
class
tdme::os::threading::Barrier
{
22
public
:
23
// forbid class copy
24
FORBID_CLASS_COPY
(
Barrier
)
25
26
/**
27
* @brief Public constructor
28
* @param name name
29
* @param count Number of threads that need to "wait" on barrier to complete barrier
30
*/
31
inline
Barrier
(const
string
&
name
, const
unsigned
int
count
):
name
(
name
),
count
(
count
),
entered
(0),
exited
(0),
m
("barrier_mutex"),
c
("barrier_condition") {}
32
33
/**
34
* @brief Destroys the barrier
35
*/
36
~Barrier
();
37
38
/**
39
* @brief Waits on barrier
40
* @return bool if caller thread is selected for updating shared data
41
*/
42
bool
wait
();
43
44
private
:
45
string
name
;
46
unsigned
int
count
;
47
volatile
unsigned
int
entered
;
48
volatile
unsigned
int
exited
;
49
Mutex
m
;
50
Condition
c
;
51
};
Condition.h
Mutex.h
tdme::os::threading::Barrier
Barrier implementation.
Definition:
Barrier.h:21
tdme::os::threading::Barrier::~Barrier
~Barrier()
Destroys the barrier.
Definition:
Barrier.cpp:14
tdme::os::threading::Barrier::count
unsigned int count
Definition:
Barrier.h:46
tdme::os::threading::Barrier::c
Condition c
Definition:
Barrier.h:50
tdme::os::threading::Barrier::name
string name
Definition:
Barrier.h:45
tdme::os::threading::Barrier::m
Mutex m
Definition:
Barrier.h:49
tdme::os::threading::Barrier::exited
volatile unsigned int exited
Definition:
Barrier.h:48
tdme::os::threading::Barrier::wait
bool wait()
Waits on barrier.
Definition:
Barrier.cpp:28
tdme::os::threading::Barrier::entered
volatile unsigned int entered
Definition:
Barrier.h:47
tdme::os::threading::Condition
Threading condition variable implementation.
Definition:
Condition.h:23
tdme::os::threading::Mutex
Mutex implementation.
Definition:
Mutex.h:19
fwd-tdme.h
tdme.h
FORBID_CLASS_COPY
#define FORBID_CLASS_COPY(CLASS)
Definition:
tdme.h:6
Generated by
1.9.1