#ifndef CC_TIMER_H #define CC_TIMER_H #pragma once #include #include "CC.h" namespace CTL { enum TimeType { Microsecond = 0, Millisecond = 1, Second = 2, Minute = 3, Hour = 4, }; class Timer { public: Timer(); ~Timer(); // 启动定时器 void Start(const std::function& callback,unsigned long count,TimeType interval = TimeType::Millisecond); // 停止定时器 void Stop(); private: IntSleep m_sleep; std::atomic m_running{}; std::thread m_thread; std::mutex m_mutex; }; } #endif