| 123456789101112131415161718192021222324252627282930313233 |
- #pragma once
- #include <iostream>
- #include <boost/asio.hpp>
- #include <boost/asio/steady_timer.hpp>
- #include <boost/asio/system_timer.hpp>
- #include <boost/asio/high_resolution_timer.hpp>
- #include <list>
- #include "ITimer.h"
- using namespace boost::posix_time;
- using namespace boost::asio;
- using namespace std;
- class TimeScheduler
- {
- public:
- void startTimer();
- void attachITimer(ITimer* pTimer);
- void detachITimer(ITimer* pTimer);
- static TimeScheduler* GetInstance() { return &instance; };
- private:
- TimeScheduler();
- ~TimeScheduler();
- TimeScheduler(const TimeScheduler&)=default;
- TimeScheduler& operator = (const TimeScheduler&) = default;
- void __onTimer(const error_code& ec);
- private:
- boost::asio::io_service io_;
- boost::asio::steady_timer timer_;
- std::list<ITimer*> m_ITimes;
- static TimeScheduler instance;
- };
|