Add SemiFuture class.
authorLee Howes <lwh@fb.com>
Thu, 5 Oct 2017 02:59:14 +0000 (19:59 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 5 Oct 2017 03:09:08 +0000 (20:09 -0700)
commita95a6976020356513a4c0dc8a3c8557c0b2b4496
tree13b8f852c04419a3d8501a646bffae23399c7aab
parenteab6da6adf08655248b054fd887005b61afdb5d6
Add SemiFuture class.

Summary:
Offer a clean separation between future as a vocabulary type for crossing
library interfaces, and future as a type to manage continuations.

The principle is that if we want an API with clean separation of execution it
should both return and receive SemiFutures. The returned SemiFuture would
only be awaitable, but not continuable. If the caller wants to enqueue a
continuation then it is efficiently convertable into a folly::Future by
calling .via.

This means that an API a) Does not have to take an executor to ensure it
returns a valid future. That can be deferred to the caller or the caller's
caller/target for true separation. b) The API can ensure that its own executor
is not exposed to the caller, while still having a clean API.

Obviously if some API wants to allow returning of a continuable future, then it
can also provide an executor-taking API.

Reviewed By: yfeldblum

Differential Revision: D5769284

fbshipit-source-id: 46241d1274bf7b1698a7d28a47cff2a65a983740
folly/Unit.h
folly/futures/Future-inl.h
folly/futures/Future-pre.h
folly/futures/Future.cpp
folly/futures/Future.h
folly/futures/Promise.h
folly/futures/test/ExecutorTest.cpp
folly/futures/test/SemiFutureTest.cpp [new file with mode: 0644]