Commit c0b4901a authored by Erik Hortsch's avatar Erik Hortsch Committed by Facebook Github Bot

Allow the tick interval to be specified on folly EventBase

Summary:
Allow the eventbase to be constructed with a higher-precision timer, for those callers that need more precision for shorter (or higher entropy) waits.

(Note: this ignores all push blocking failures!)

Differential Revision: D15186374

fbshipit-source-id: 98cca2d15fc18f9e865129f4629a4351e9a8b9c9
parent 578c4b91
......@@ -274,6 +274,17 @@ class EventBase : public TimeoutManager,
Function<void()> f_;
};
/**
* Create a new EventBase object.
*
* Same as EventBase(true), which constructs an EventBase that measures time,
* except that this also allows the timer granularity to be specified
*/
explicit EventBase(std::chrono::milliseconds tickInterval) : EventBase(true) {
intervalDuration_ = tickInterval;
}
/**
* Create a new EventBase object.
*
......@@ -648,7 +659,7 @@ class EventBase : public TimeoutManager,
HHWheelTimer& timer() {
if (!wheelTimer_) {
wheelTimer_ = HHWheelTimer::newTimer(this);
wheelTimer_ = HHWheelTimer::newTimer(this, intervalDuration_);
}
return *wheelTimer_.get();
}
......@@ -826,6 +837,9 @@ class EventBase : public TimeoutManager,
void initNotificationQueue();
// Tick granularity to wheelTimer_
std::chrono::milliseconds intervalDuration_{
HHWheelTimer::DEFAULT_TICK_INTERVAL};
// should only be accessed through public getter
HHWheelTimer::UniquePtr wheelTimer_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment