More refactoring

This commit is contained in:
King_DuckZ 2020-08-09 20:47:04 +01:00
parent 73ec4446ea
commit c0461f6b09
6 changed files with 61 additions and 47 deletions

28
src/timer_items.cpp Normal file
View file

@ -0,0 +1,28 @@
#include "timer_items.hpp"
#include "eventia/private/context.hpp"
#include "roar11/ThreadPool.hpp"
#include <cassert>
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