Botan
3.10.0
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
#include <mutex>
10
11
namespace
Botan
{
12
13
void
Barrier::wait
(
size_t
delta) {
14
std::scoped_lock<std::mutex>
lock
(m_mutex);
15
m_value += delta;
16
}
17
18
void
Barrier::sync
() {
19
std::unique_lock<std::mutex>
lock
(m_mutex);
20
21
if
(m_value > 1) {
22
--m_value;
23
const
size_t
current_syncs = m_syncs;
24
m_cond.wait(
lock
, [
this
, ¤t_syncs] {
return
m_syncs != current_syncs; });
25
}
else
{
26
m_value = 0;
27
++m_syncs;
28
m_cond.notify_all();
29
}
30
}
31
32
}
// namespace Botan
Botan::Barrier::wait
void wait(size_t delta)
Definition
barrier.cpp:13
Botan::Barrier::sync
void sync()
Definition
barrier.cpp:18
Botan
Definition
alg_id.cpp:13
Botan::lock
secure_vector< T > lock(const std::vector< T > &in)
Definition
secmem.h:81
Generated by
1.15.0