Make DestructorGuard inherit from a base
authorSophia Wang <xiaosophiawang@fb.com>
Wed, 15 Jul 2015 00:18:18 +0000 (17:18 -0700)
committerSara Golemon <sgolemon@fb.com>
Wed, 15 Jul 2015 20:25:12 +0000 (13:25 -0700)
commitf46045c9827ef489a6c3ccefd269042b1ae19a08
tree1089c7500fd7abd85fea3b9385dd704b73348265
parenta1107271b093884b8bb4b4dfd911533a46bae61b
Make DestructorGuard inherit from a base

Summary: There are more use cases that the Destruction/Guard pattern can be
used than current DelayedDestruction provides. This diff makes the pattern more
general (remove self destruct) and lets DelayedDestruction derive from that.
The functionalities of DelayedDestruction is kept unchanged.

I leave destroy(), Destructor class, and destroyPending_ in DelayedDestruction
since they are not required by our CallbackGuard in proxygen.

I add a shouldDestruct() function to allow customized conditions on when to
call destructor.

I haven't made destroyNow() a std::function since I only need it to be set at
instatiation time. If there is any other use case that needs destroyNow() to be
a std::function, I can do that as well.

Reviewed By: @afrind

Differential Revision: D2202575
folly/Makefile.am
folly/io/async/DelayedDestruction.h
folly/io/async/DelayedDestructionBase.h [new file with mode: 0644]
folly/io/async/test/DelayedDestructionBaseTest.cpp [new file with mode: 0644]
folly/io/async/test/UndelayedDestruction.h