aboutsummaryrefslogtreecommitdiff
path: root/src/timer.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/timer.hpp')
-rw-r--r--src/timer.hpp90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/timer.hpp b/src/timer.hpp
index 5055a3d8..685e83b9 100644
--- a/src/timer.hpp
+++ b/src/timer.hpp
@@ -1,64 +1,64 @@
#pragma once
-
-// ReSharper disable once CppUnusedIncludeDirective
#include "pre.hpp"
-#include "system_headers.hpp"
-#include <map>
#include <chrono>
#include <functional>
+#include <map>
#include <optional>
+#include "system_headers.hpp"
#include "base.hpp"
-namespace cru
-{
- using TimerAction = std::function<void()>;
+namespace cru {
+using TimerAction = std::function<void()>;
+
+class TimerManager : public Object {
+ public:
+ static TimerManager* GetInstance();
- class TimerManager : public Object
- {
- public:
- static TimerManager* GetInstance();
+ private:
+ TimerManager() = default;
- private:
- TimerManager() = default;
- public:
- TimerManager(const TimerManager& other) = delete;
- TimerManager(TimerManager&& other) = delete;
- TimerManager& operator=(const TimerManager& other) = delete;
- TimerManager& operator=(TimerManager&& other) = delete;
- ~TimerManager() override = default;
+ public:
+ TimerManager(const TimerManager& other) = delete;
+ TimerManager(TimerManager&& other) = delete;
+ TimerManager& operator=(const TimerManager& other) = delete;
+ TimerManager& operator=(TimerManager&& other) = delete;
+ ~TimerManager() override = default;
- UINT_PTR CreateTimer(UINT milliseconds, bool loop, const TimerAction& action);
- void KillTimer(UINT_PTR id);
- std::optional<std::pair<bool, TimerAction>> GetAction(UINT_PTR id);
+ UINT_PTR CreateTimer(UINT milliseconds, bool loop, const TimerAction& action);
+ void KillTimer(UINT_PTR id);
+ std::optional<std::pair<bool, TimerAction>> GetAction(UINT_PTR id);
- private:
- std::map<UINT_PTR, std::pair<bool, TimerAction>> map_{};
- UINT_PTR current_count_ = 0;
- };
+ private:
+ std::map<UINT_PTR, std::pair<bool, TimerAction>> map_{};
+ UINT_PTR current_count_ = 0;
+};
- class TimerTask
- {
- friend TimerTask SetTimeout(std::chrono::milliseconds milliseconds, const TimerAction& action);
- friend TimerTask SetInterval(std::chrono::milliseconds milliseconds, const TimerAction& action);
+class TimerTask {
+ friend TimerTask SetTimeout(std::chrono::milliseconds milliseconds,
+ const TimerAction& action);
+ friend TimerTask SetInterval(std::chrono::milliseconds milliseconds,
+ const TimerAction& action);
- private:
- explicit TimerTask(UINT_PTR id);
+ private:
+ explicit TimerTask(UINT_PTR id);
- public:
- TimerTask(const TimerTask& other) = default;
- TimerTask(TimerTask&& other) = default;
- TimerTask& operator=(const TimerTask& other) = default;
- TimerTask& operator=(TimerTask&& other) = default;
- ~TimerTask() = default;
+ public:
+ TimerTask(const TimerTask& other) = default;
+ TimerTask(TimerTask&& other) = default;
+ TimerTask& operator=(const TimerTask& other) = default;
+ TimerTask& operator=(TimerTask&& other) = default;
+ ~TimerTask() = default;
- void Cancel() const;
+ void Cancel() const;
- private:
- UINT_PTR id_;
- };
+ private:
+ UINT_PTR id_;
+};
- TimerTask SetTimeout(std::chrono::milliseconds milliseconds, const TimerAction& action);
- TimerTask SetInterval(std::chrono::milliseconds milliseconds, const TimerAction& action);
-}
+TimerTask SetTimeout(std::chrono::milliseconds milliseconds,
+ const TimerAction& action);
+TimerTask SetInterval(std::chrono::milliseconds milliseconds,
+ const TimerAction& action);
+} // namespace cru