Group parameters in a TimerSettings struct
This commit is contained in:
parent
a3153bcc66
commit
2d62b44ebc
4 changed files with 24 additions and 17 deletions
|
@ -61,6 +61,7 @@ void test(oro::Api* api, oro::OriginsDB* db, std::size_t extra_delay, std::size_
|
|||
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);
|
||||
|
@ -71,10 +72,10 @@ void test(oro::Api* api, oro::OriginsDB* db, std::size_t extra_delay, std::size_
|
|||
|
||||
auto sig_int = worker.make_event<SignalInt>(&worker);
|
||||
|
||||
auto timer_items = worker.make_event<TimerItems>(0.0, ed, &pool, api, db);
|
||||
auto timer_icons = worker.make_event<TimerIcons>(5.0, ed, &pool, api, db);
|
||||
auto timer_shops = worker.make_event<TimerShops>(10.0, ed, &pool, api, db);
|
||||
auto timer_creat = worker.make_event<TimerCreators>(15.0, ed, &pool, api, db);
|
||||
auto timer_items = worker.make_event<TimerItems>(TSet{0.0, ed}, &pool, api, db);
|
||||
auto timer_icons = worker.make_event<TimerIcons>(TSet{5.0, ed}, &pool, api, db);
|
||||
auto timer_shops = worker.make_event<TimerShops>(TSet{10.0, ed}, &pool, api, db);
|
||||
auto timer_creat = worker.make_event<TimerCreators>(TSet{15.0, ed}, &pool, api, db);
|
||||
|
||||
worker.wait();
|
||||
#if !defined(NDEBUG)
|
||||
|
|
|
@ -55,14 +55,13 @@ namespace {
|
|||
TimerBase::TimerBase (
|
||||
const eve::Context& ctx,
|
||||
oro::DBOperation type,
|
||||
double min_wait,
|
||||
double extra_wait,
|
||||
const TimerSettings& settings,
|
||||
roar11::ThreadPool* pool,
|
||||
oro::Api* oro_api,
|
||||
oro::OriginsDB* db
|
||||
) :
|
||||
eve::Timer(initial_timer(*db, type, min_wait), ctx),
|
||||
m_extra_wait(extra_wait),
|
||||
eve::Timer(initial_timer(*db, type, settings.min_wait), ctx),
|
||||
m_extra_delay(settings.extra_delay),
|
||||
m_pool(pool),
|
||||
m_oro_api(oro_api),
|
||||
m_db(db)
|
||||
|
@ -76,7 +75,7 @@ void TimerBase::on_timer() {
|
|||
}
|
||||
|
||||
void TimerBase::set_next_timer (const oro::Header& header) {
|
||||
const unsigned long next_timer = time_interval(header) + m_extra_wait;
|
||||
const unsigned long next_timer = time_interval(header) + m_extra_delay;
|
||||
std::cout << "Next timer in " << next_timer << " secs\n";
|
||||
this->set_timer(static_cast<double>(next_timer));
|
||||
}
|
||||
|
|
|
@ -37,13 +37,22 @@ namespace oro {
|
|||
|
||||
namespace duck {
|
||||
|
||||
struct TimerSettings {
|
||||
TimerSettings (double min_wait, double extra_delay) :
|
||||
min_wait(min_wait),
|
||||
extra_delay(extra_delay)
|
||||
{ }
|
||||
|
||||
double min_wait;
|
||||
double extra_delay;
|
||||
};
|
||||
|
||||
class TimerBase : public eve::Timer {
|
||||
public:
|
||||
TimerBase (
|
||||
const eve::Context& ctx,
|
||||
oro::DBOperation type,
|
||||
double min_wait,
|
||||
double extra_wait,
|
||||
const TimerSettings& settings,
|
||||
roar11::ThreadPool* pool,
|
||||
oro::Api* oro_api,
|
||||
oro::OriginsDB* db
|
||||
|
@ -65,7 +74,7 @@ protected:
|
|||
private:
|
||||
virtual void fetch_data() = 0;
|
||||
|
||||
double m_extra_wait;
|
||||
double m_extra_delay;
|
||||
roar11::ThreadPool* m_pool;
|
||||
oro::Api* m_oro_api;
|
||||
oro::OriginsDB* m_db;
|
||||
|
|
|
@ -33,8 +33,7 @@ class TimerOroApi : TimerBase {
|
|||
public:
|
||||
TimerOroApi (
|
||||
const eve::Context& ctx,
|
||||
double min_wait,
|
||||
double extra_wait,
|
||||
const TimerSettings& settings,
|
||||
roar11::ThreadPool* pool,
|
||||
oro::Api* oro_api,
|
||||
oro::OriginsDB* db
|
||||
|
@ -71,13 +70,12 @@ namespace detail {
|
|||
template<oro::DBOperation Op>
|
||||
inline TimerOroApi<Op>::TimerOroApi (
|
||||
const eve::Context& ctx,
|
||||
double min_wait,
|
||||
double extra_wait,
|
||||
const TimerSettings& settings,
|
||||
roar11::ThreadPool* pool,
|
||||
oro::Api* oro_api,
|
||||
oro::OriginsDB* db
|
||||
) :
|
||||
TimerBase(ctx, Op, min_wait, extra_wait, pool, oro_api, db)
|
||||
TimerBase(ctx, Op, settings, pool, oro_api, db)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue