Move runAfterDelay/tryRunAfterDelay into TimeoutManager
[folly.git] / folly / io / async / EventBase.h
index 16d406eaa898c205bbcb5f05a2487fdd1d21b713..a8d4926f26ac0c05e16c8d6f7b78fe0c05741532 100644 (file)
@@ -397,28 +397,6 @@ class EventBase : private boost::noncopyable,
    */
   bool runImmediatelyOrRunInEventBaseThreadAndWait(Func fn);
 
-  /**
-   * Runs the given Cob at some time after the specified number of
-   * milliseconds.  (No guarantees exactly when.)
-   *
-   * Throws a std::system_error if an error occurs.
-   */
-  void runAfterDelay(
-      Func c,
-      uint32_t milliseconds,
-      TimeoutManager::InternalEnum in = TimeoutManager::InternalEnum::NORMAL);
-
-  /**
-   * @see tryRunAfterDelay for more details
-   *
-   * @return  true iff the cob was successfully registered.
-   *
-   * */
-  bool tryRunAfterDelay(
-      Func cob,
-      uint32_t milliseconds,
-      TimeoutManager::InternalEnum in = TimeoutManager::InternalEnum::NORMAL);
-
   /**
    * Set the maximum desired latency in us and provide a callback which will be
    * called when that latency is exceeded.
@@ -430,7 +408,6 @@ class EventBase : private boost::noncopyable,
     maxLatencyCob_ = std::move(maxLatencyCob);
   }
 
-
   /**
    * Set smoothing coefficient for loop load average; # of milliseconds
    * for exp(-1) (1/2.71828...) decay.
@@ -602,22 +579,23 @@ class EventBase : private boost::noncopyable,
     return LoopKeepAlive(this);
   }
 
- private:
   // TimeoutManager
-  void attachTimeoutManager(AsyncTimeout* obj,
-                            TimeoutManager::InternalEnum internal) override;
+  void attachTimeoutManager(
+      AsyncTimeout* obj,
+      TimeoutManager::InternalEnum internal) override final;
 
-  void detachTimeoutManager(AsyncTimeout* obj) override;
+  void detachTimeoutManager(AsyncTimeout* obj) override final;
 
   bool scheduleTimeout(AsyncTimeout* obj, TimeoutManager::timeout_type timeout)
-    override;
+      override final;
 
-  void cancelTimeout(AsyncTimeout* obj) override;
+  void cancelTimeout(AsyncTimeout* obj) override final;
 
   bool isInTimeoutManagerThread() override final {
     return isInEventBaseThread();
   }
 
+ private:
   void applyLoopKeepAlive();
 
   /*
@@ -626,30 +604,6 @@ class EventBase : private boost::noncopyable,
    */
   bool nothingHandledYet() const noexcept;
 
-  // small object used as a callback arg with enough info to execute the
-  // appropriate client-provided Cob
-  class CobTimeout : public AsyncTimeout {
-   public:
-    CobTimeout(EventBase* b, Func c, TimeoutManager::InternalEnum in)
-        : AsyncTimeout(b, in), cob_(std::move(c)) {}
-
-    virtual void timeoutExpired() noexcept;
-
-   private:
-    Func cob_;
-
-   public:
-    typedef boost::intrusive::list_member_hook<
-      boost::intrusive::link_mode<boost::intrusive::auto_unlink> > ListHook;
-
-    ListHook hook;
-
-    typedef boost::intrusive::list<
-      CobTimeout,
-      boost::intrusive::member_hook<CobTimeout, ListHook, &CobTimeout::hook>,
-      boost::intrusive::constant_time_size<false> > List;
-  };
-
   typedef LoopCallback::List LoopCallbackList;
   class FunctionRunner;
 
@@ -663,8 +617,6 @@ class EventBase : private boost::noncopyable,
   // should only be accessed through public getter
   HHWheelTimer::UniquePtr wheelTimer_;
 
-  CobTimeout::List pendingCobTimeouts_;
-
   LoopCallbackList loopCallbacks_;
   LoopCallbackList runBeforeLoopCallbacks_;
   LoopCallbackList onDestructionCallbacks_;