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