2020-08-10 11:22:25 +01:00
|
|
|
/* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-08-01 07:02:54 +02:00
|
|
|
#include "evloop.hpp"
|
2020-08-10 19:19:06 +01:00
|
|
|
#include "timer_generic.hpp"
|
2020-08-09 19:26:18 +01:00
|
|
|
#include "eventia/eventia.hpp"
|
2020-08-09 20:04:22 +01:00
|
|
|
#include "roar11/ThreadPool.hpp"
|
2020-08-09 21:07:54 +01:00
|
|
|
#include "oro/api.hpp"
|
2020-08-09 19:26:18 +01:00
|
|
|
#include <iostream>
|
2020-08-01 07:02:54 +02:00
|
|
|
|
2020-08-09 19:26:18 +01:00
|
|
|
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);
|
|
|
|
// }
|
2020-08-01 07:02:54 +02:00
|
|
|
|
2020-08-09 19:26:18 +01:00
|
|
|
// void on_timer_ev() {
|
|
|
|
// }
|
|
|
|
//};
|
2020-08-09 17:29:37 +01:00
|
|
|
|
2020-08-09 20:04:22 +01:00
|
|
|
void join(roar11::ThreadPool& pool) {
|
2020-08-09 19:26:18 +01:00
|
|
|
pool.join();
|
|
|
|
std::cout << "all tasks completed\n";
|
2020-08-01 07:24:45 +02:00
|
|
|
}
|
|
|
|
|
2020-08-09 19:26:18 +01:00
|
|
|
} //unnamed namespace
|
2020-08-01 07:24:45 +02:00
|
|
|
|
2020-08-10 02:34:09 +01:00
|
|
|
void test(oro::Api* api, oro::OriginsDB* db) {
|
2020-08-10 19:19:06 +01:00
|
|
|
typedef TimerGeneric<&oro::Api::market_list> TimerShops;
|
|
|
|
typedef TimerGeneric<&oro::Api::items_list> TimerItems;
|
|
|
|
typedef TimerGeneric<&oro::Api::items_icons> TimerIcons;
|
|
|
|
|
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;
|
2020-08-09 19:26:18 +01:00
|
|
|
pool.submit(worker.event_functor());
|
2020-08-09 17:29:37 +01:00
|
|
|
|
2020-08-10 18:48:00 +01:00
|
|
|
auto timer_items = worker.make_timer<TimerItems>(5.0, &pool, api, db);
|
|
|
|
auto timer_icons = worker.make_timer<TimerIcons>(10.0, &pool, api, db);
|
|
|
|
auto timer_shops = worker.make_timer<TimerShops>(15.0, &pool, api, db);
|
2020-08-09 17:29:37 +01:00
|
|
|
|
2020-08-09 19:26:18 +01:00
|
|
|
join(pool);
|
2020-08-01 07:02:54 +02:00
|
|
|
}
|
|
|
|
} //namespace duck
|