#include "evloop.hpp"
#include "html_fetch_task.hpp"
#include "eventia/eventia.hpp"
#include "eventia/timer.hpp"
#include "orotool_config.hpp"
#if THREADPOOL == THREADPOOL_TASKFLOW
# include
#elif THREADPOOL == THREADPOOL_ROAR11
# include "roar11/ThreadPool.hpp"
#endif
#include
#if THREADPOOL == THREADPOOL_TASKFLOW
namespace tf {
class Taskflow;
class Subflow;
} //namespace tf
#elif THREADPOOL == THREADPOOL_ROAR11
namespace roar11 {
class ThreadPool;
} //namespace roar11
#endif
namespace duck {
namespace {
#if THREADPOOL == THREADPOOL_ROAR11
typedef roar11::ThreadPool threadpool_type;
typedef roar11::ThreadPool subpool_type;
#elif THREADPOOL == THREADPOOL_TASKFLOW
typedef tf::Taskflow threadpool_type;
typedef tf::Subflow subpool_type;
#endif
//class KeepaliveTimer : public ev::timer {
//public:
// KeepaliveTimer (ev::loop_ref& loop, RunningPool::subpool_type*) {
// this->set(loop);
// this->set(this);
// ev::timer::start(5.0, 5.0);
// }
// void on_timer_ev() {
// }
//};
#if THREADPOOL == THREADPOOL_TASKFLOW
void join(tf::Executor& executor) {
executor.wait_for_all();
std::cout << "all tasks completed\n";
}
#else
void join(threadpool_type& pool) {
pool.join();
std::cout << "all tasks completed\n";
}
#endif
} //unnamed namespace
void test() {
roar11::ThreadPool pool(std::max(2U, std::thread::hardware_concurrency()) - 1);
eve::Eventia worker;
pool.submit(worker.event_functor());
std::cout << "Instantiating html timer\n";
auto fetcher = worker.make_timer(&pool, "test_url_lol");
join(pool);
}
} //namespace duck