getVia() and waitVia()
authorJames Sedgwick <jsedgwick@fb.com>
Wed, 21 Jan 2015 21:39:03 +0000 (13:39 -0800)
committerwoo <woo@fb.com>
Mon, 2 Feb 2015 21:12:16 +0000 (13:12 -0800)
commit9f916e143c9efad2f24cf6b62c90c8ac7895f71b
treec9aaaf4211a56c921df548d670b3763f10873d9d
parentff1b7be8909060849721a42b1851099e80cd3d40
getVia() and waitVia()

Summary:
Introduce ProgressableExecutor, which is an Executor that can be driven somehow. Examples include EventBase and ManualExecutor
Then introduce Future<T>::getVia(ProgressableExecutor*) and Future<T>::waitVia(ProgressableExecutor*) that drive the given executor until the Future is complete, with the usual semantics of get and wait respectively
This is a really common pattern in tests and you can see in the various changes to other projects lends sopme nice redness and cleanliness

Some notes:
1. I don't like ProgressableExecutor::makeProgress() that much. Too verbose. Maybe DrivableExecutor::drive()? Something else? Thoughts?
2. I still need to integrate this with some stuff in Zeus (SessionFuture) and Zookeeper (ZookeeperFuture) but I'm going to do that in a separate diff because it's going to be a little more intrusive
3. These APIs take a raw ptr so that they are consistent with via()
4. See inline note on ManualExecutor
5. See inline note in added unit tests

Test Plan: add unit for new API, wait for contbuild

Reviewed By: hans@fb.com

Subscribers: trunkagent, dresende, pzq, tdimson, fbcode-common-diffs@, targeting-diff-backend@, alandau, apollo-diffs@, bmatheny, everstore-dev@, zhuohuang, laser-diffs@, mshneer, folly-diffs@, hannesr, jsedgwick

FB internal diff: D1789122

Tasks: 5940008

Signature: t1:1789122:1421868315:6ea2fc2702be1dc283c24a46d345fb5da3935b32
folly/Makefile.am
folly/futures/DrivableExecutor.h [new file with mode: 0644]
folly/futures/Future-inl.h
folly/futures/Future.h
folly/futures/ManualExecutor.h
folly/futures/ScheduledExecutor.h
folly/futures/test/FutureTest.cpp
folly/futures/test/ViaTest.cpp
folly/io/async/EventBase.h