CppBenchmark  1.0.4.0
C++ Benchmark Library
benchmark_threads.h
Go to the documentation of this file.
1 
9 #ifndef CPPBENCHMARK_BENCHMARK_THREADS_H
10 #define CPPBENCHMARK_BENCHMARK_THREADS_H
11 
16 
17 #include <thread>
18 
19 namespace CppBenchmark {
20 
22 
25 class BenchmarkThreads : public BenchmarkBase, public virtual FixtureThreads
26 {
27 public:
30 
32 
36  template<typename... Types>
37  explicit BenchmarkThreads(const std::string& name, Types... settings) : BenchmarkThreads(name, TSettings(settings...)) {}
39 
43  explicit BenchmarkThreads(const std::string& name, const TSettings& settings) : BenchmarkBase(name, settings) {}
46  virtual ~BenchmarkThreads() = default;
47 
50 
51 protected:
53 
58  virtual void RunThread(ContextThreads& context) = 0;
59 
60 private:
61  std::vector<std::thread> _threads;
62 
63  int CountLaunches() const override;
64  void Launch(int& current, int total, LauncherHandler& handler) override;
65 };
66 
69 } // namespace CppBenchmark
70 
71 #endif // CPPBENCHMARK_BENCHMARK_THREADS_H
Benchmark base definition.
Benchmark base class.
const Settings & settings() const
Get benchmark settings.
const std::string & name() const
Get benchmark name.
Threads benchmark base class.
BenchmarkThreads & operator=(const BenchmarkThreads &)=delete
virtual ~BenchmarkThreads()=default
SettingsThreads TSettings
BenchmarkThreads settings type.
BenchmarkThreads(const std::string &name, const TSettings &settings)
Alternative class constructor.
BenchmarkThreads & operator=(BenchmarkThreads &&)=delete
BenchmarkThreads(BenchmarkThreads &&)=delete
virtual void RunThread(ContextThreads &context)=0
Thread run method.
BenchmarkThreads(const BenchmarkThreads &)=delete
BenchmarkThreads(const std::string &name, Types... settings)
Default class constructor.
Benchmark thread running context.
Threads benchmark fixture.
Threads benchmark settings.
Benchmark thread running context definition.
Threads benchmark fixture definition.
C++ Benchmark project definitions.
Definition: barrier.h:15
Threads benchmark settings definition.