hproselet/worker.hpp

25 lines
508 B
C++
Raw Permalink Normal View History

2022-12-15 02:05:06 +00:00
#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