aboutsummaryrefslogtreecommitdiff
path: root/CruUI/timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'CruUI/timer.h')
-rw-r--r--CruUI/timer.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/CruUI/timer.h b/CruUI/timer.h
index 70913775..9884e46a 100644
--- a/CruUI/timer.h
+++ b/CruUI/timer.h
@@ -2,10 +2,9 @@
#include "system_headers.h"
-#include <functional>
#include <memory>
#include <map>
-#include <optional>
+#include <chrono>
#include "base.h"
#include "application.h"
@@ -28,20 +27,17 @@ namespace cru
TimerManager& operator=(TimerManager&& other) = delete;
~TimerManager() override = default;
- UINT_PTR CreateTimer(UINT milliseconds, bool loop, std::shared_ptr<Action<>> action);
+ UINT_PTR CreateTimer(UINT milliseconds, bool loop, ActionPtr action);
void KillTimer(UINT_PTR id);
- std::shared_ptr<Action<>> GetAction(UINT_PTR id);
+ ActionPtr GetAction(UINT_PTR id);
private:
- std::map<UINT_PTR, std::shared_ptr<Action<>>> map_{};
+ std::map<UINT_PTR, ActionPtr> map_{};
UINT_PTR current_count_ = 0;
};
- struct ITimerTask : virtual Interface
- {
- virtual void Cancel() = 0;
- };
+ using TimerTask = CancelablePtr;
- std::shared_ptr<ITimerTask> SetTimeout(double seconds, std::shared_ptr<Action<>> action);
- std::shared_ptr<ITimerTask> SetInterval(double seconds, std::shared_ptr<Action<>> action);
+ TimerTask SetTimeout(std::chrono::milliseconds milliseconds, ActionPtr action);
+ TimerTask SetInterval(std::chrono::milliseconds milliseconds, ActionPtr action);
}