Add internal mode for HHWheelTimer
authorAlan Frindell <afrind@fb.com>
Mon, 8 Jun 2015 16:37:42 +0000 (09:37 -0700)
committerSara Golemon <sgolemon@fb.com>
Tue, 9 Jun 2015 20:20:42 +0000 (13:20 -0700)
Summary:
This allows an EventBase to exit loop() even if there are pending timeouts in the timer (make sure to cancelAll before deleting!)

Test Plan: Unit tests

Reviewed By: davejwatson@fb.com

Subscribers: doug, folly-diffs@, yfeldblum, chalfant

FB internal diff: D2111942

Signature: t1:2111942:1432934212:7ac1973bdbbfdbda714699ab373618399f29ef76

folly/io/async/HHWheelTimer.cpp
folly/io/async/HHWheelTimer.h

index a75dc7340b5db1dd69806b1caa3edaf5eac0258a..2bc9eae772c3054b8aaf0f4151db1fdb50b7e582 100644 (file)
@@ -76,8 +76,9 @@ void HHWheelTimer::Callback::cancelTimeoutImpl() {
 }
 
 HHWheelTimer::HHWheelTimer(folly::EventBase* eventBase,
-                           std::chrono::milliseconds intervalMS)
-  : AsyncTimeout(eventBase)
+                           std::chrono::milliseconds intervalMS,
+                           AsyncTimeout::InternalEnum internal)
+  : AsyncTimeout(eventBase, internal)
   , interval_(intervalMS)
   , nextTick_(1)
   , count_(0)
index 86e670636f3afa38049c146e59b4b7310b380c85..56ded208aaf6e61633856da5768032c0192a5ede 100644 (file)
@@ -153,7 +153,9 @@ class HHWheelTimer : private folly::AsyncTimeout,
   static int DEFAULT_TICK_INTERVAL;
   explicit HHWheelTimer(folly::EventBase* eventBase,
                         std::chrono::milliseconds intervalMS =
-                        std::chrono::milliseconds(DEFAULT_TICK_INTERVAL));
+                        std::chrono::milliseconds(DEFAULT_TICK_INTERVAL),
+                        AsyncTimeout::InternalEnum internal =
+                        AsyncTimeout::InternalEnum::NORMAL);
 
   /**
    * Destroy the HHWheelTimer.