X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fio%2Fasync%2FHHWheelTimer.cpp;h=1fd5e6d25d81b041bf691c154b610b63664bd456;hp=366b5eeb7a47e0f00f5bd91c8707d1e07671334f;hb=81bb353a7a807bc48cb06e50a9db84613df0cbce;hpb=6a36073a00ac3a1fd23be79ad720a963f86bf9e3 diff --git a/folly/io/async/HHWheelTimer.cpp b/folly/io/async/HHWheelTimer.cpp index 366b5eeb..1fd5e6d2 100644 --- a/folly/io/async/HHWheelTimer.cpp +++ b/folly/io/async/HHWheelTimer.cpp @@ -77,9 +77,11 @@ void HHWheelTimer::Callback::cancelTimeoutImpl() { HHWheelTimer::HHWheelTimer(folly::EventBase* eventBase, std::chrono::milliseconds intervalMS, - AsyncTimeout::InternalEnum internal) + AsyncTimeout::InternalEnum internal, + std::chrono::milliseconds defaultTimeoutMS) : AsyncTimeout(eventBase, internal) , interval_(intervalMS) + , defaultTimeout_(defaultTimeoutMS) , nextTick_(1) , count_(0) , catchupEveryN_(DEFAULT_CATCHUP_EVERY_N) @@ -137,6 +139,12 @@ void HHWheelTimer::scheduleTimeout(Callback* callback, count_++; } +void HHWheelTimer::scheduleTimeout(Callback* callback) { + CHECK(std::chrono::milliseconds(-1) != defaultTimeout_) + << "Default timeout was not initialized"; + scheduleTimeout(callback, defaultTimeout_); +} + bool HHWheelTimer::cascadeTimers(int bucket, int tick) { CallbackList cbs; cbs.swap(buckets_[bucket][tick]);