Allow a timer with pending callbacks to be destroyed
authorChad Parry <cparry@fb.com>
Thu, 9 Jun 2016 22:07:58 +0000 (15:07 -0700)
committerFacebook Github Bot 6 <facebook-github-bot-6-bot@fb.com>
Thu, 9 Jun 2016 22:08:29 +0000 (15:08 -0700)
commit3f6e3b45bd73d9aa9827c7f680d2676a0a91f4c5
tree884dafc2f6f2f95e718ed7b779c68300ac6922b0
parent2488a9d52aa326ef1096d29caa95491bb71133f0
Allow a timer with pending callbacks to be destroyed

Summary:
This diff is part of a string of changes that is getting `HHWheelTimer` to use standard smart pointers.

D2617966 is being reverted. The `DestructorGuard` that was added for safety is not possible without intrusive reference counting.
That means that the `count_` (of pending callbacks) will still be correct, but there will be nothing to check it against. Because of that, I removed the assertions to make sure that the count of pending callbacks matches the count of active guards. Anyway, there were already ways to defeat that test, such as by creating a `DestructorGuard` from any client code.
As long as the assertions are gone, the `cancelAll` can be moved to the destructor. It only ever got run when `destroy` was called and `count_` was `0`, which means that `~HHWheelTimer` was also going to get called at the same time.

Reviewed By: djwatson

Differential Revision: D3349303

fbshipit-source-id: 433fa6605ee9921833328e2f82bd07b2e17e42c5
folly/io/async/HHWheelTimer.cpp
folly/io/async/HHWheelTimer.h