中间件底层,websocket

Scheduler.h 775B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef __SCHEDULER_H__
  2. #define __SCHEDULER_H__
  3. #include <boost\bind.hpp>
  4. #include <chrono>
  5. #include <thread>
  6. #include <boost/asio.hpp>
  7. #include <atomic>
  8. #include <shared_mutex>
  9. class CScheduler
  10. {
  11. typedef CScheduler this_type;
  12. public:
  13. CScheduler(boost::asio::io_service& ios);
  14. ~CScheduler();
  15. void setTimer(const std::int32_t& nIDEvent, const std::int32_t& uElapse);
  16. void killTimer();
  17. typedef std::function<void(std::int32_t)> FimeFunCB;
  18. void setOnTimeFuncCB(FimeFunCB fun) ;
  19. private:
  20. void __onTimer();
  21. private:
  22. boost::asio::steady_timer timer_; // 定时器
  23. std::int32_t m_DuratTime; // 定时器间隔,单位毫秒
  24. std::atomic_bool m_IsStop; // 定时器是否关闭
  25. std::shared_mutex m_IsStopLock; //
  26. FimeFunCB m_FunCB; //
  27. std::int32_t m_TimeId; // 定时器ID
  28. };
  29. #endif