orotool/src/evloop.cpp

41 lines
1 KiB
C++

#include "evloop.hpp"
#include "timer_items.hpp"
#include "eventia/eventia.hpp"
#include "eventia/timer.hpp"
#include "roar11/ThreadPool.hpp"
#include "oro/api.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(oro::Api* api) {
const std::size_t thread_count = 2U; //std::min(std::max(3U, std::thread::hardware_concurrency()) - 1, 4U);
std::cout << "Running with " << thread_count << " worker threads\n";
roar11::ThreadPool pool(thread_count);
eve::Eventia worker;
pool.submit(worker.event_functor());
auto fetcher = worker.make_timer<TimerItems>(3.0, &pool, api);
join(pool);
}
} //namespace duck