ソースを参照

Fix Timer Bug

JDierkse 6 年 前
コミット
3357229b5a
2 ファイル変更8 行追加2 行削除
  1. 5 0
      Util/Timer.cpp
  2. 3 2
      Util/Timer.h

+ 5 - 0
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;

+ 3 - 2
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>(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);
 				}
 			});