aboutsummaryrefslogtreecommitdiff
path: root/CruUI/timer.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-09-19 01:15:01 +0800
committercrupest <crupest@outlook.com>2018-09-19 01:15:01 +0800
commit85bb4d466efeb2540363065d7c0987a9d60f70e9 (patch)
treeea5e5aa738afb37a2d3bc4e74f9be64c15f3d188 /CruUI/timer.h
parent4710715102df3806479985679bd8048631ccaab5 (diff)
downloadcru-85bb4d466efeb2540363065d7c0987a9d60f70e9.tar.gz
cru-85bb4d466efeb2540363065d7c0987a9d60f70e9.tar.bz2
cru-85bb4d466efeb2540363065d7c0987a9d60f70e9.zip
finish animation!!!
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);
}