CppBenchmark 1.0.5.0
C++ Benchmark Library
Loading...
Searching...
No Matches
barrier.h
Go to the documentation of this file.
1
9#ifndef CPPBENCHMARK_BARRIER_H
10#define CPPBENCHMARK_BARRIER_H
11
12#include <condition_variable>
13#include <mutex>
14
15namespace CppBenchmark {
16
18
27{
28public:
30
33 explicit Barrier(int threads) noexcept;
34 Barrier(const Barrier&) = delete;
35 Barrier(Barrier&&) = delete;
36 ~Barrier() = default;
37
38 Barrier& operator=(const Barrier&) = delete;
40
42
47 bool Wait() noexcept;
48
49private:
50 std::mutex _mutex;
51 std::condition_variable _cond;
52 int _counter;
53 int _generation;
54 int _threads;
55};
56
57} // namespace CppBenchmark
58
59#endif // CPPBENCHMARK_BARRIER_H
Barrier synchronization primitive.
Definition barrier.h:27
Barrier & operator=(Barrier &&)=delete
Barrier(Barrier &&)=delete
Barrier(const Barrier &)=delete
bool Wait() noexcept
Wait at the barrier until all other threads reach this barrier.
Definition barrier.cpp:20
Barrier & operator=(const Barrier &)=delete
C++ Benchmark project definitions.
Definition barrier.h:15