Botan 3.4.0
Crypto and TLS for C&
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
10namespace Botan {
11
12void Barrier::wait(size_t delta) {
13 std::lock_guard<std::mutex> lock(m_mutex);
14 m_value += delta;
15}
16
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, &current_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
void wait(size_t delta)
Definition barrier.cpp:12
secure_vector< T > lock(const std::vector< T > &in)
Definition secmem.h:70