Botan
3.6.1
Crypto and TLS for C&
src
lib
utils
thread_utils
barrier.cpp
Go to the documentation of this file.
1
/*
2
* Barrier
3
* (C) 2016 Joel Low
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#include <botan/internal/barrier.h>
9
10
namespace
Botan
{
11
12
void
Barrier::wait
(
size_t
delta) {
13
std::lock_guard<std::mutex>
lock
(m_mutex);
14
m_value += delta;
15
}
16
17
void
Barrier::sync
() {
18
std::unique_lock<std::mutex>
lock
(m_mutex);
19
20
if
(m_value > 1) {
21
--m_value;
22
const
size_t
current_syncs = m_syncs;
23
m_cond.wait(
lock
, [
this
, ¤t_syncs] {
return
m_syncs != current_syncs; });
24
}
else
{
25
m_value = 0;
26
++m_syncs;
27
m_cond.notify_all();
28
}
29
}
30
31
}
// namespace Botan
Botan::Barrier::wait
void wait(size_t delta)
Definition
barrier.cpp:12
Botan::Barrier::sync
void sync()
Definition
barrier.cpp:17
Botan
Definition
alg_id.cpp:13
Botan::lock
secure_vector< T > lock(const std::vector< T > &in)
Definition
secmem.h:70
Generated by
1.12.0