add consumeUntilDrained API to NotificationQueue::Consumer
authorJames Sedgwick <jsedgwick@fb.com>
Thu, 4 Dec 2014 18:29:24 +0000 (10:29 -0800)
committerDave Watson <davejwatson@fb.com>
Thu, 11 Dec 2014 16:00:25 +0000 (08:00 -0800)
commit35ed5364f1ba809d6d103c98c03ae951aab3bc05
tree1efea9105b65e85df9ce943530684b991403ed7a
parent6fdeaebacf7f89fd40a3c866a7f60eee66a805d5
add consumeUntilDrained API to NotificationQueue::Consumer

Summary:
... and employ it in EventBase's destructor to stop leaking memory from unexecuted NotificationQueue-variety runInEventBaseThread() callbacks

in addition to the attached task, this should also fix the root cause of the already-worked-around #5564342

Test Plan:
test no longer leaks.* on the other hand, IOThreadPoolExecutor::stop() no longer actually stops, it joins. I added comments to stop() in headers indicating that it should be treated as best-effort.

* hilariously, this actually isn't true - there's a new leak of a thread local inside the io pool because callbacks can outlive the pool now. i'll leave a full explanation for the upcoming patch.

Reviewed By: davejwatson@fb.com

Subscribers: alandau, bmatheny, mshneer, trunkagent, fugalh, njormrod, folly-diffs@

FB internal diff: D1682860

Tasks: 5336655

Signature: t1:1682860:1416347774:ac5f31fb72373992f425c93ac284a0cd27608db4
folly/experimental/wangle/concurrent/IOThreadPoolExecutor.h
folly/experimental/wangle/concurrent/ThreadPoolExecutor.h
folly/experimental/wangle/concurrent/test/ThreadPoolExecutorTest.cpp
folly/io/async/EventBase.cpp
folly/io/async/EventBase.h
folly/io/async/NotificationQueue.h
folly/io/async/test/EventBaseTest.cpp