Introduce destruction callbacks
Summary:
This change allows users to track lifetime of EventBase and perform clean shutdown when EventBase gets destructed.
It is useful for users that rely on EventBase lifetime, but don't have any feedback mechanism with the owner of EventBase.
For instance some part of code might remain running in background on the EventBase after the main object was destroyed (e.g. it might be finalizing some async requests). In such case the original owner doesn't know that there's something still running and may try to destroy EventBase. In that case such background code will remain zombie forever.
AsyncMcClient changes are presented just as an example of usage.
@davejwatson, @simpkins: Could you please take a look at the proposed changes for the EventBase? If this is something not worth adding into EventBase, could you recommend a better way of doing things?
Test Plan: fbmake runtests
Reviewed By: alikhtarov@fb.com
Subscribers: folly@lists, simpkins, davejwatson
FB internal diff:
D1353101