diff options
author | Yuri Gorshenin <ygorshenin@chromium.org> | 2015-03-13 17:55:10 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:41:24 +0300 |
commit | 2b0f4125289657beaa71b80f5897052d36521104 (patch) | |
tree | 31a656501d5afcc9d296c878ebed88aa9b71ce1f /map/benchmark_engine.cpp | |
parent | f7203eb9b75a01270d63e74e8eccebdf531c5742 (diff) |
[thread] Refactored lifetime management of multithreaded tasks.
Diffstat (limited to 'map/benchmark_engine.cpp')
-rw-r--r-- | map/benchmark_engine.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/map/benchmark_engine.cpp b/map/benchmark_engine.cpp index 3f7863b931..50598c3493 100644 --- a/map/benchmark_engine.cpp +++ b/map/benchmark_engine.cpp @@ -243,29 +243,31 @@ bool BenchmarkEngine::NextBenchmarkCommand() void BenchmarkEngine::Start() { - m_thread.Create(this); + m_thread.Create(make_unique<Routine>(*this)); } -void BenchmarkEngine::Do() +BenchmarkEngine::Routine::Routine(BenchmarkEngine & engine) : m_engine(engine) {} + +void BenchmarkEngine::Routine::Do() { - PrepareMaps(); + m_engine.PrepareMaps(); int benchMarkCount = 1; (void) Settings::Get("BenchmarkCyclesCount", benchMarkCount); for (int i = 0; i < benchMarkCount; ++i) { - DoGetBenchmarks doGet(*this); + DoGetBenchmarks doGet(m_engine); ForEachBenchmarkRecord(doGet); - m_curBenchmark = 0; + m_engine.m_curBenchmark = 0; - m_benchmarksTimer.Reset(); - m_startTime = my::FormatCurrentTime(); + m_engine.m_benchmarksTimer.Reset(); + m_engine.m_startTime = my::FormatCurrentTime(); - MarkBenchmarkResultsStart(); - while (NextBenchmarkCommand()){}; + m_engine.MarkBenchmarkResultsStart(); + while (m_engine.NextBenchmarkCommand()){}; - m_benchmarks.clear(); + m_engine.m_benchmarks.clear(); } } |