#ifndef __SCHEDULER_H__ #define __SCHEDULER_H__ #include #include #include #include #include #include class CScheduler { typedef CScheduler this_type; public: CScheduler(); CScheduler(boost::asio::io_service& ios); ~CScheduler(); void setTimer(const std::int32_t& nIDEvent, const std::int32_t& uElapse); void killTimer(); typedef std::function FimeFunCB; void setOnTimeFuncCB(FimeFunCB fun) ; private: void __onTimer(); private: boost::asio::io_service m_ios; boost::asio::io_service::work work; boost::asio::steady_timer timer_; // 定时器 std::unique_ptr m_pThread;// 异步线程 std::int32_t m_DuratTime; // 定时器间隔,单位毫秒 std::atomic_bool m_IsStop; // 定时器是否关闭 std::shared_mutex m_IsStopLock; // FimeFunCB m_FunCB; // std::int32_t m_TimeId; // 定时器ID }; #endif