Expose the time remaining in HHWheelTimer::Callback
[folly.git] / folly / io / async / HHWheelTimer.h
index d670e3baf069f8168bc6dcb38c679aee88bfc991..5544c2d661b8ecc2305e893b0ab5a32950257593 100644 (file)
@@ -54,7 +54,6 @@ namespace folly {
 class HHWheelTimer : private folly::AsyncTimeout,
                      public folly::DelayedDestruction {
  public:
-  // This type has always been a misnomer, because it is not a unique pointer.
   using UniquePtr = std::unique_ptr<HHWheelTimer, Destructor>;
   using SharedPtr = std::shared_ptr<HHWheelTimer>;
 
@@ -105,6 +104,15 @@ class HHWheelTimer : private folly::AsyncTimeout,
       return wheel_ != nullptr;
     }
 
+    /**
+     * Get the time remaining until this timeout expires. Return 0 if this
+     * timeout is not scheduled or expired. Otherwise, return expiration time
+     * minus getCurTime().
+     */
+    std::chrono::milliseconds getTimeRemaining() {
+      return getTimeRemaining(getCurTime());
+    }
+
    protected:
     /**
      * Don't override this unless you're doing a test. This is mainly here so