X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fio%2Fasync%2FEventBase.h;h=660b1abdf93d3852f79628341736faa514de78d9;hp=fdee81348b13ca27ef7877c723fc3f4c3475d43e;hb=d816ed8879e9748b1c17de98617b35d5060ec8b0;hpb=3ed4f961b8a78a0806246254c140eef467aab202 diff --git a/folly/io/async/EventBase.h b/folly/io/async/EventBase.h index fdee8134..660b1abd 100644 --- a/folly/io/async/EventBase.h +++ b/folly/io/async/EventBase.h @@ -240,6 +240,18 @@ class EventBase : private boost::noncopyable, public TimeoutManager { void runInLoop(Cob&& c, bool thisIteration = false); + /** + * Adds the given callback to a queue of things run before destruction + * of current EventBase. + * + * This allows users of EventBase that run in it, but don't control it, + * to be notified before EventBase gets destructed. + * + * Note: will be called from the thread that invoked EventBase destructor, + * before the final run of loop callbacks. + */ + void runOnDestruction(LoopCallback* callback); + /** * Run the specified function in the EventBase's thread. * @@ -500,6 +512,7 @@ class EventBase : private boost::noncopyable, public TimeoutManager { CobTimeout::List pendingCobTimeouts_; LoopCallbackList loopCallbacks_; + LoopCallbackList onDestructionCallbacks_; // This will be null most of the time, but point to currentCallbacks // if we are in the middle of running loop callbacks, such that