benchmark 1.10.0
Loading...
Searching...
No Matches
thread_manager.h
1#ifndef BENCHMARK_THREAD_MANAGER_H
2#define BENCHMARK_THREAD_MANAGER_H
3
4#include <atomic>
5
6#include "benchmark/counter.h"
7#include "benchmark/statistics.h"
8#include "benchmark/types.h"
9#include "mutex.h"
10
11namespace benchmark {
12namespace internal {
13
14class ThreadManager {
15 public:
16 explicit ThreadManager(int num_threads) : start_stop_barrier_(num_threads) {}
17
18 Mutex& GetBenchmarkMutex() const RETURN_CAPABILITY(benchmark_mutex_) {
19 return benchmark_mutex_;
20 }
21
22 bool StartStopBarrier() { return start_stop_barrier_.wait(); }
23
24 void NotifyThreadComplete() { start_stop_barrier_.removeThread(); }
25
26 struct Result {
27 IterationCount iterations = 0;
28 double real_time_used = 0;
29 double cpu_time_used = 0;
30 double manual_time_used = 0;
31 int64_t complexity_n = 0;
32 std::string report_label_;
33 std::string skip_message_;
34 internal::Skipped skipped_ = internal::NotSkipped;
35 UserCounters counters;
36 };
37 GUARDED_BY(GetBenchmarkMutex()) Result results;
38
39 private:
40 mutable Mutex benchmark_mutex_;
41 Barrier start_stop_barrier_;
42};
43
44} // namespace internal
45} // namespace benchmark
46
47#endif // BENCHMARK_THREAD_MANAGER_H
Definition mutex.h:114
Definition thread_manager.h:26