Commit 02cae39d authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

std::chrono'ize EventBase::setLoadAvgMsec

Summary: Modernization is good.

Reviewed By: yfeldblum

Differential Revision: D4377612

fbshipit-source-id: adb03d8a92f25c8a792c8e7240a93ab20180b038
parent 7b4bb3f5
......@@ -205,10 +205,10 @@ void EventBase::setMaxReadAtOnce(uint32_t maxAtOnce) {
// Set smoothing coefficient for loop load average; input is # of milliseconds
// for exp(-1) decay.
void EventBase::setLoadAvgMsec(uint32_t ms) {
void EventBase::setLoadAvgMsec(std::chrono::milliseconds ms) {
assert(enableTimeMeasurement_);
std::chrono::microseconds us = std::chrono::milliseconds(ms);
if (ms > 0) {
if (ms > std::chrono::milliseconds::zero()) {
maxLatencyLoopTime_.setTimeInterval(us);
avgLoopTime_.setTimeInterval(us);
} else {
......
......@@ -447,7 +447,7 @@ class EventBase : private boost::noncopyable,
* Set smoothing coefficient for loop load average; # of milliseconds
* for exp(-1) (1/2.71828...) decay.
*/
void setLoadAvgMsec(uint32_t ms);
void setLoadAvgMsec(std::chrono::milliseconds ms);
/**
* reset the load average to a desired value
......
......@@ -47,6 +47,8 @@ using std::chrono::milliseconds;
using std::chrono::microseconds;
using std::chrono::duration_cast;
using namespace std::chrono_literals;
using namespace folly;
///////////////////////////////////////////////////////////////////////////
......@@ -1563,7 +1565,7 @@ class IdleTimeTimeoutSeries : public AsyncTimeout {
*/
TEST(EventBaseTest, IdleTime) {
EventBase eventBase;
eventBase.setLoadAvgMsec(1000);
eventBase.setLoadAvgMsec(1000ms);
eventBase.resetLoadAvg(5900.0);
std::deque<uint64_t> timeouts0(4, 8080);
timeouts0.push_front(8000);
......
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