/* Copyright 2020, Michele Santullo
* This file is part of orotool.
*
* Orotool is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Orotool is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Orotool. If not, see .
*/
#include "evloop.hpp"
#include "timer_items.hpp"
#include "timer_icons.hpp"
#include "eventia/eventia.hpp"
#include "roar11/ThreadPool.hpp"
#include "oro/api.hpp"
#include
namespace duck {
namespace {
//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() {
// }
//};
void join(roar11::ThreadPool& pool) {
pool.join();
std::cout << "all tasks completed\n";
}
} //unnamed namespace
void test(oro::Api* api, oro::OriginsDB* db) {
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 timer_items = worker.make_timer(3.0, &pool, api, db);
auto timer_icons = worker.make_timer(20.0, &pool, api, db);
join(pool);
}
} //namespace duck