Use intrusive base hook rather than a member hook
authorChristopher Dykes <cdykes@fb.com>
Fri, 26 Aug 2016 17:51:13 +0000 (10:51 -0700)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Fri, 26 Aug 2016 17:53:27 +0000 (10:53 -0700)
Summary: Because MSVC is not happy about the member hook when used in complex inheritence scenarios.

Reviewed By: yfeldblum

Differential Revision: D3774513

fbshipit-source-id: 9e1ef8dd76d966de339f8486ff1a1d0ab1571849

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

index 6433581e83cd91935160e681c911d086967b85e1..ca372502b481f6b18c2c68cb48189068febc0370 100644 (file)
@@ -68,7 +68,7 @@ void HHWheelTimer::Callback::cancelTimeoutImpl() {
     assert(wheel_->count_ == 0);
     wheel_->AsyncTimeout::cancelTimeout();
   }
-  hook_.unlink();
+  unlink();
   if ((-1 != bucket_) && (wheel_->buckets_[0][bucket_].empty())) {
     auto bi = makeBitIterator(wheel_->bitmap_.begin());
     *(bi + bucket_) = false;
index 33af9f34b020b76f5547fb5984b9dc22df90a593..4c33239db012f0532d9d78affd88ec2b627e6249 100644 (file)
@@ -66,7 +66,9 @@ class HHWheelTimer : private folly::AsyncTimeout,
   /**
    * A callback to be notified when a timeout has expired.
    */
-  class Callback {
+  class Callback
+      : public boost::intrusive::list_base_hook<
+            boost::intrusive::link_mode<boost::intrusive::auto_unlink>> {
    public:
     Callback()
       : wheel_(nullptr)
@@ -134,14 +136,8 @@ class HHWheelTimer : private folly::AsyncTimeout,
     std::chrono::milliseconds expiration_;
     int bucket_{-1};
 
-    typedef boost::intrusive::list_member_hook<
-      boost::intrusive::link_mode<boost::intrusive::auto_unlink> > ListHook;
-
-    ListHook hook_;
-
     typedef boost::intrusive::list<
       Callback,
-      boost::intrusive::member_hook<Callback, ListHook, &Callback::hook_>,
       boost::intrusive::constant_time_size<false> > List;
 
     std::shared_ptr<RequestContext> context_;