25 lines
508 B
C++
25 lines
508 B
C++
|
#ifndef _WORKER_HPP_
|
||
|
#define _WORKER_HPP_
|
||
|
|
||
|
#ifndef ASIO_STANDALONE
|
||
|
#define ASIO_STANDALONE
|
||
|
#endif
|
||
|
#include <asio.hpp>
|
||
|
|
||
|
#include "timer.hpp"
|
||
|
|
||
|
class Worker : public asio::io_context {
|
||
|
|
||
|
};
|
||
|
|
||
|
class TimerdWorker : public Worker , public TimerService {
|
||
|
public:
|
||
|
std::weak_ptr<Timer> AddTimer(const timer_callback& cb, uint32_t wait, uint32_t interval) {
|
||
|
auto timer = std::make_shared<Timer>(*this, cb, wait, interval);
|
||
|
timer->Begin();
|
||
|
return std::weak_ptr<Timer>(timer);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
#endif
|