implement AtomicTimer::zeroize() that resets start_time and total_time

This commit is contained in:
sasha 2022-02-28 17:41:26 -08:00
parent 0f06774e94
commit 0e13aba1b7
2 changed files with 13 additions and 0 deletions

View File

@ -50,6 +50,17 @@ void AtomicTimer::stop()
}
}
void AtomicTimer::zeroize()
{
std::unique_lock<std::mutex> 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<std::mutex> lock(mtx);

View File

@ -52,6 +52,8 @@ public:
*/
void stop();
void zeroize();
bool running();
uint64_t threadCount();