orotool/src/evloop.cpp

43 lines
1.1 KiB
C++
Raw Normal View History

#include "evloop.hpp"
2020-08-09 20:47:04 +01:00
#include "timer_items.hpp"
2020-08-10 02:34:09 +01:00
#include "timer_icons.hpp"
#include "eventia/eventia.hpp"
#include "roar11/ThreadPool.hpp"
2020-08-09 21:07:54 +01:00
#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
2020-08-10 02:34:09 +01:00
void test(oro::Api* api, oro::OriginsDB* db) {
2020-08-09 20:47:04 +01:00
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);
2020-08-09 19:28:39 +01:00
eve::Eventia worker;
pool.submit(worker.event_functor());
2020-08-10 02:34:09 +01:00
auto timer_items = worker.make_timer<TimerItems>(3.0, &pool, api, db);
auto timer_icons = worker.make_timer<TimerIcons>(20.0, &pool, api, db);
join(pool);
}
} //namespace duck