Restore the definition of HHWheelTimer::UniquePtr
authorChad Parry <cparry@fb.com>
Thu, 12 Nov 2015 00:02:35 +0000 (16:02 -0800)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Thu, 12 Nov 2015 00:20:20 +0000 (16:20 -0800)
Summary: Changing the definition of `HHWheelTimer::UniquePtr` wasn't safe, because some clients were using that type outside of the `HHWheelTimer::newTimer` helper. I'm changing that part back. We'll still be able to proceed with my other codemod to `HHWheelTimer`, but we'll always have two different smart pointer types to manage: `UniquePtr` and `IntrusivePtr`.

Reviewed By: djwatson

Differential Revision: D2644721

fb-gh-sync-id: 14685be62355f09d39c4139ef7186d60b5f48dcd

folly/io/async/HHWheelTimer.h

index 17a74d54eb61597e87f1ee2d9fffe48720673c30..e8e678da0f16d3e783527ab2ffc9d4cca9f3ac77 100644 (file)
@@ -60,15 +60,12 @@ 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 = IntrusivePtr<HHWheelTimer>;
+  using UniquePtr = std::unique_ptr<HHWheelTimer, Destructor>;
+  using SharedPtr = IntrusivePtr<HHWheelTimer>;
 
   template <typename... Args>
   static UniquePtr newTimer(Args&&... args) {
-    std::unique_ptr<HHWheelTimer, Destructor> instance(
-        new HHWheelTimer(std::forward<Args>(args)...));
-    // Avoid the weird semantics of the Destructor by managing ownership
-    // entirely from the IntrusivePtr.
-    return UniquePtr(instance);
+    return UniquePtr(new HHWheelTimer(std::forward<Args>(args)...));
   }
 
   /**