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
Showing
Please register or sign in to comment