#include "timer_items.hpp" #include "eventia/private/context.hpp" #include "roar11/ThreadPool.hpp" #include namespace duck { TimerItems::TimerItems (const eve::Context& ctx, double timeout, roar11::ThreadPool* pool) : eve::Timer(timeout, ctx), m_pool(pool) { assert(m_pool); } void TimerItems::on_timer() { m_pool->submit(&TimerItems::fetch_data, this); } void TimerItems::fetch_data() { using namespace std::chrono_literals; std::cout << "Timer elapsed! Doing fake work...\n"; std::this_thread::sleep_for(5s); const double new_delay = 5.0; std::cout << "Now starting next timer for " << new_delay << " seconds\n"; set_timer(new_delay); } } //namespace duck