Fix Timer Bug

This commit is contained in:
2019-04-15 11:17:36 +02:00
parent 7539890b5c
commit 3357229b5a
2 changed files with 8 additions and 2 deletions
+5
View File
@@ -42,6 +42,11 @@ bool Timer::operator==(const std::string& identifier) const
return m_identifier == identifier; return m_identifier == identifier;
} }
bool Timer::operator==(bool running) const
{
return IsRunning() == running;
}
std::string Timer::Identifier() const std::string Timer::Identifier() const
{ {
return m_identifier; return m_identifier;
+3 -2
View File
@@ -24,6 +24,7 @@ public:
bool operator==(const Timer& other) const; bool operator==(const Timer& other) const;
bool operator==(const std::string& identifier) const; bool operator==(const std::string& identifier) const;
bool operator==(bool running) const;
public: public:
std::string Identifier() const; std::string Identifier() const;
@@ -66,7 +67,7 @@ private:
if (m_run.load(std::memory_order_acquire)) if (m_run.load(std::memory_order_acquire))
Stop(); 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>(arguments)...); auto argumentsCopy = std::make_tuple(std::forward<Arguments>(arguments)...);
m_run.store(true, std::memory_order_release); m_run.store(true, std::memory_order_release);
@@ -75,7 +76,7 @@ private:
{ {
std::this_thread::sleep_for(std::chrono::milliseconds(interval)); std::this_thread::sleep_for(std::chrono::milliseconds(interval));
Helpers::execute(function, argumentsCopy); Helpers::execute(function, argumentsCopy);
if (TimerType::Single) if (type == TimerType::Single)
m_run.store(false, std::memory_order_release); m_run.store(false, std::memory_order_release);
} }
}); });