diff --git a/Util/Timer.cpp b/Util/Timer.cpp index 2865eb8..0d2b822 100644 --- a/Util/Timer.cpp +++ b/Util/Timer.cpp @@ -42,6 +42,11 @@ bool Timer::operator==(const std::string& identifier) const return m_identifier == identifier; } +bool Timer::operator==(bool running) const +{ + return IsRunning() == running; +} + std::string Timer::Identifier() const { return m_identifier; diff --git a/Util/Timer.h b/Util/Timer.h index 9bb491f..723ff8f 100644 --- a/Util/Timer.h +++ b/Util/Timer.h @@ -24,6 +24,7 @@ public: bool operator==(const Timer& other) const; bool operator==(const std::string& identifier) const; + bool operator==(bool running) const; public: std::string Identifier() const; @@ -66,7 +67,7 @@ private: if (m_run.load(std::memory_order_acquire)) Stop(); - m_thread = std::thread([this, interval, function, &arguments...]() + m_thread = std::thread([this, type, interval, function, &arguments...]() { auto argumentsCopy = std::make_tuple(std::forward(arguments)...); m_run.store(true, std::memory_order_release); @@ -75,7 +76,7 @@ private: { std::this_thread::sleep_for(std::chrono::milliseconds(interval)); Helpers::execute(function, argumentsCopy); - if (TimerType::Single) + if (type == TimerType::Single) m_run.store(false, std::memory_order_release); } });