Botan 3.10.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#include <mutex>
10
11namespace Botan {
12
13void Barrier::wait(size_t delta) {
14 std::scoped_lock<std::mutex> lock(m_mutex);
15 m_value += delta;
16}
17
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, &current_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
void wait(size_t delta)
Definition barrier.cpp:13
secure_vector< T > lock(const std::vector< T > &in)
Definition secmem.h:81