diff options
| author | crupest <crupest@outlook.com> | 2018-11-07 21:40:04 +0800 |
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2018-11-07 21:40:04 +0800 |
| commit | efdce672123284847bd7fb6f12ac1ec96f28f3ef (patch) | |
| tree | 298e6313e9a48c5867b2355242b78d3cd23fdc61 /src/timer.h | |
| parent | 634dab6ad2c9e4675beacfb77ac02b2d43cab132 (diff) | |
| download | cru-efdce672123284847bd7fb6f12ac1ec96f28f3ef.tar.gz cru-efdce672123284847bd7fb6f12ac1ec96f28f3ef.tar.bz2 cru-efdce672123284847bd7fb6f12ac1ec96f28f3ef.zip | |
Make all header *.hpp .
Diffstat (limited to 'src/timer.h')
| -rw-r--r-- | src/timer.h | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/src/timer.h b/src/timer.h deleted file mode 100644 index 0fac2cdd..00000000 --- a/src/timer.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once - - -#include "system_headers.h" -#include <map> -#include <chrono> -#include <functional> -#include <optional> - -#include "base.h" - -namespace cru -{ - using TimerAction = std::function<void()>; - - class TimerManager : public Object - { - public: - TimerManager() = default; - 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); - - 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); - - 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; - - void Cancel(); - - private: - UINT_PTR id_; - }; - - TimerTask SetTimeout(std::chrono::milliseconds milliseconds, const TimerAction& action); - TimerTask SetInterval(std::chrono::milliseconds milliseconds, const TimerAction& action); -} |
