Botan 3.6.1
Crypto and TLS for C&
barrier.h
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#ifndef BOTAN_UTIL_BARRIER_H_
9#define BOTAN_UTIL_BARRIER_H_
10
11#include <condition_variable>
12#include <mutex>
13
14namespace Botan {
15
16/**
17Barrier implements a barrier synchronization primitive. wait() will
18indicate how many threads to synchronize; each thread needing
19synchronization should call sync(). When sync() returns, the barrier
20is reset to zero, and the m_syncs counter is incremented. m_syncs is a
21counter to ensure that wait() can be called after a sync() even if the
22previously sleeping threads have not awoken.)
23*/
25 public:
26 explicit Barrier(int value = 0) : m_value(value), m_syncs(0) {}
27
28 void wait(size_t delta);
29
30 void sync();
31
32 private:
33 size_t m_value;
34 size_t m_syncs;
35 std::mutex m_mutex;
36 std::condition_variable m_cond;
37};
38
39} // namespace Botan
40
41#endif
void wait(size_t delta)
Definition barrier.cpp:12
Barrier(int value=0)
Definition barrier.h:26
int(* final)(unsigned char *, CTX *)