From 0e13aba1b7ca66725d8f932c766f5baf76002a29 Mon Sep 17 00:00:00 2001 From: sasha Date: Mon, 28 Feb 2022 17:41:26 -0800 Subject: [PATCH] implement AtomicTimer::zeroize() that resets start_time and total_time --- src/metrics.cpp | 11 +++++++++++ src/metrics.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/metrics.cpp b/src/metrics.cpp index e243171ff..0dc6c88b9 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -50,6 +50,17 @@ void AtomicTimer::stop() } } + +void AtomicTimer::zeroize() +{ + std::unique_lock lock(mtx); + // only zeroize it if there's no more threads (same semantics as start()) + if (threads < 1) { + start_time = 0; + total_time = 0; + } +} + bool AtomicTimer::running() { std::unique_lock lock(mtx); diff --git a/src/metrics.h b/src/metrics.h index e20473287..a29621f9a 100644 --- a/src/metrics.h +++ b/src/metrics.h @@ -52,6 +52,8 @@ public: */ void stop(); + void zeroize(); + bool running(); uint64_t threadCount();