#pragma once #include "system_headers.h" #include #include #include #include #include "base.h" #include "application.h" namespace cru { class TimerManager : public Object { public: static TimerManager* GetInstance() { return Application::GetInstance()->GetTimerManager(); } 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, std::shared_ptr> action); void KillTimer(UINT_PTR id); std::shared_ptr> GetAction(UINT_PTR id); private: std::map>> map_{}; UINT_PTR current_count_ = 0; }; struct ITimerTask : virtual Interface { virtual void Cancel() = 0; }; std::shared_ptr SetTimeout(double seconds, std::shared_ptr> action); std::shared_ptr SetInterval(double seconds, std::shared_ptr> action); }