Pass app_config to test() instead of single options

This commit is contained in:
King_DuckZ 2020-09-05 00:59:51 +01:00
parent 9d4d52bed0
commit 8f8865e4df
3 changed files with 10 additions and 13 deletions

View file

@ -21,6 +21,7 @@
#include "eventia/signal.hpp"
#include "roar11/ThreadPool.hpp"
#include "oro/dboperation.hpp"
#include "app_config.hpp"
#include <iostream>
namespace duck {
@ -56,22 +57,22 @@ namespace {
};
} //unnamed namespace
void test(oro::Api* api, oro::OriginsDB* db, std::size_t extra_delay, std::size_t thread_count, bool store_raw_json) {
void test(oro::Api* api, oro::OriginsDB* db, const AppConfig& app_conf) {
typedef TimerOroApi<oro::DBOperation::Shops> TimerShops;
typedef TimerOroApi<oro::DBOperation::Items> TimerItems;
typedef TimerOroApi<oro::DBOperation::Icons> TimerIcons;
typedef TimerOroApi<oro::DBOperation::Creators> TimerCreators;
typedef TimerSettings TSet;
std::cout << "Running with " << thread_count << " worker threads\n";
roar11::ThreadPool pool(thread_count);
std::cout << "Running with " << app_conf.worker_threads() << " worker threads\n";
roar11::ThreadPool pool(app_conf.worker_threads());
eve::Eventia worker;
pool.submit(worker.event_functor());
const double ed = static_cast<double>(extra_delay);
const double ed = static_cast<double>(app_conf.fetch_extra_delay());
auto sig_int = worker.make_event<SignalInt>(&worker);
const bool& rj = store_raw_json;
const bool rj = app_conf.store_raw_json();
auto timer_items = worker.make_event<TimerItems>(TSet{0.0, ed, rj}, &pool, api, db);
auto timer_icons = worker.make_event<TimerIcons>(TSet{5.0, ed, rj}, &pool, api, db);