Introduce destruction callbacks
authorStepan Palamarchuk <stepan@fb.com>
Thu, 5 Jun 2014 05:33:39 +0000 (22:33 -0700)
committerAnton Likhtarov <alikhtarov@fb.com>
Mon, 9 Jun 2014 22:35:58 +0000 (15:35 -0700)
commitd816ed8879e9748b1c17de98617b35d5060ec8b0
treed66cd20d857313e4cbe2a6990e1ca63031aa7cc8
parent3ed4f961b8a78a0806246254c140eef467aab202
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
folly/io/async/EventBase.cpp
folly/io/async/EventBase.h