Commit 46af81b6 authored by Lee Howes's avatar Lee Howes Committed by Facebook Github Bot

Split SemiFuture and Future into separate types. Add BasicFuture shared between them.

Summary:
To avoid the risk of bugs caused by a Future being cast to a SemiFuture, and losing some of the properties in the process, this splits SemiFuture and Future into unrelated types, sharing a private superclass for code reuse.
 * Add BasicFuture in futures::detail
 * Make superclass privately inherited.
 * Unset executor when constructing SemiFuture from Future.

Reviewed By: yfeldblum

Differential Revision: D6177780

fbshipit-source-id: dea3116aeec0572bb973c2a561e17785199e86f2
parent cceed93a
This diff is collapsed.
This diff is collapsed.
......@@ -29,6 +29,8 @@ template <class T> class Future;
namespace futures {
namespace detail {
template <class T>
class FutureBase;
struct EmptyConstruct {};
template <typename T, typename F>
class CoreCallbackState;
......@@ -110,8 +112,11 @@ class Promise {
private:
typedef typename Future<T>::corePtr corePtr;
template <class>
friend class futures::detail::FutureBase;
template <class>
friend class SemiFuture;
template <class> friend class Future;
template <class>
friend class Future;
template <class, class>
friend class futures::detail::CoreCallbackState;
......
......@@ -203,7 +203,7 @@ TEST(SemiFuture, MakeFutureFromSemiFutureLValue) {
Promise<int> p;
std::atomic<int> result{0};
auto f = SemiFuture<int>{p.getFuture()};
auto future = f.via(&e).then([&](int value) {
auto future = std::move(f).via(&e).then([&](int value) {
result = value;
return value;
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment