#include #include "Util.h" #include "Timer.h" namespace PresenceDetection { namespace Util { Timer::Timer() : m_run(false), m_identifier(CreateRandomString(10)) { } Timer::~Timer() { Wait(); } bool Timer::operator==(const Timer& other) const { return m_identifier == other.Identifier(); } std::string Timer::Identifier() const { return m_identifier; } void Timer::Stop() { m_run.store(false, std::memory_order_release); } bool Timer::IsRunning() const noexcept { return (m_run.load(std::memory_order_acquire) && m_thread.joinable()); } void Timer::Wait() { if (m_thread.joinable()) m_thread.join(); } } // namespace Util } // namespace PresenceDetection