orotool/src/evloop.cpp

40 lines
916 B
C++
Raw Normal View History

#include "evloop.hpp"
#include "html_fetch_task.hpp"
#include "eventia/eventia.hpp"
#include "eventia/timer.hpp"
#include "roar11/ThreadPool.hpp"
#include <iostream>
namespace duck {
namespace {
//class KeepaliveTimer : public ev::timer {
//public:
// KeepaliveTimer (ev::loop_ref& loop, RunningPool::subpool_type*) {
// this->set(loop);
// this->set<KeepaliveTimer, &KeepaliveTimer::on_timer_ev>(this);
// ev::timer::start(5.0, 5.0);
// }
// void on_timer_ev() {
// }
//};
void join(roar11::ThreadPool& pool) {
pool.join();
std::cout << "all tasks completed\n";
}
} //unnamed namespace
void test() {
roar11::ThreadPool pool(std::max(2U, std::thread::hardware_concurrency()) - 1);
2020-08-09 19:28:39 +01:00
eve::Eventia worker;
pool.submit(worker.event_functor());
std::cout << "Instantiating html timer\n";
auto fetcher = worker.make_timer<HtmlFetchTimer>(&pool, "test_url_lol");
join(pool);
}
} //namespace duck