Fix copyright lines Summary: [Folly] Fix copyright lines based on file histories. Reviewed By: spalamarchuk Differential Revision: D6720312 fbshipit-source-id: c70a667a1977e70e2d4451ea624f96163982f681
Make consistent set of get and getTry methods on SemiFuture. Summary: Complete set of get and getVia methods including addition of a result operation on FutureBase that provides functionality of the old getTry on Future by returning a Try by reference. Reviewed By: yfeldblum Differential Revision: D6640056 fbshipit-source-id: 3ac01f7bc4b128e641f08d9a99280a18ffce82f9
Add getVia and getTryVia to SemiFuture. Summary: Add getVia and getTryVia to SemiFuture to allow driving chains of work conveniently in the current thread. Reviewed By: yfeldblum Differential Revision: D6631898 fbshipit-source-id: 324ef342a44d4ef502188b3cffde17103f0e6cb2
Move getTry to subclasses. Summary: Move getTry from FutureBase to Future and SemiFuture. Make SemiFuture version move the result out for consistency with get. Reviewed By: yfeldblum Differential Revision: D6638561 fbshipit-source-id: 551c0f06ed52ef6d8976a5971a5e90b3ab793da0
Add getSemiFuture to folly::Promise Summary: Also deprecates folly::getFuture function. Reviewed By: yfeldblum Differential Revision: D6594299 fbshipit-source-id: 67435f35dca660da049cd8c505ee9a21424c0d2b
Add missing check against SemiFuture in FutureBase ctor Summary: [Folly] Add missing check against `SemiFuture` in `FutureBase` ctor. Reviewed By: LeeHowes Differential Revision: D6469021 fbshipit-source-id: 0ca31461afee4bf64725e065a8cb4d5e933d2013
Missing Future/SemiFuture->Value conversion check Summary: Conversion check was lost in an earlier refactor. This meant that SemiFuture could be accidentally converted to Future through the value constructor. This should be disabled. Reviewed By: yfeldblum Differential Revision: D6214526 fbshipit-source-id: 3fc2d026ec6062b38b9500c8adf3eee12c0f2693
Adding DeferredExecutor to support deferred execution of tasks on a future returned from an interface. Summary: This adds a DeferredExecutor type that is boostable, which means that it follows the expectation we expect for C++20 that .then and get will trigger boost-blocking behaviour and ensure work makes progress. Unlike discussions for C++ this adds boost blocking to folly only in the specific case of deferring work to run on the caller's executor, to avoid the necessity to pass an executor into a library purely to ensure that finalisation work and future completion occor on a well-defined exewcutor. Reviewed By: yfeldblum Differential Revision: D5828743 fbshipit-source-id: 9a4b69d7deaa33c3cecd6546651b99cc99f0c286
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
move futures/DrivableExecutor to executors/DrivableExecutor Summary: as title Reviewed By: yfeldblum Differential Revision: D6062437 fbshipit-source-id: 4f99e779e280fdb0b1f035013caff18764e86ab5
4-way overloads for SemiFuture::value Summary: [Folly] 4-way overloads for `SemiFuture::value`. Overload on the receiver reference category and `const`-qualification, deriving the return type reference category and `const`-qualification. Like `Optional`, `Try`, etc. Differential Revision: D6062006 fbshipit-source-id: d7396cd4d4bb62e99445d5f61cb360898fa1c3f3
future.then() is identical to future.unit() Summary: Document that `future.then()` is identical to `future.unit()`. Put functions next to each other to make it clear, and use identical wording. Reviewed By: yfeldblum Differential Revision: D5955451 fbshipit-source-id: 1b55d5785dc0995d4d9364f48241e98ad01b31f4
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
Don't allow Future::onError([](exception_wrapper&){}) to compile Summary: `Future::onError` does not work with a function that takes `exception_wrapper&`, so it should not compile. `exception_wrapper`, `const exception_wrapper&`, and `exception_wrapper&&` are unaffected. Reviewed By: yfeldblum Differential Revision: D5556083 fbshipit-source-id: 45d096d9fee00322eeec6b9b9b1dcbef55cced03
Consistency in namespace-closing comments Summary: [Folly] Consistency in namespace-closing comments. Reviewed By: Orvid Differential Revision: D5524744 fbshipit-source-id: ced4dd2398ed6baa3ad5b68b74eee6a5d6b2b103
Drop a remnant of gcc48 support in futures Summary: [Folly] Drop a remnant of gcc48 support in futures. Because gcc48 is no longer supported. Reviewed By: Orvid, meyering Differential Revision: D5460788 fbshipit-source-id: 86e2985a0980357641d18f59fd25b9667ec30ab0
Move futures helper types into folly::futures::detail Summary: [Folly] Move futures helper types into `folly::futures::detail`. From `folly::detail`, where it would be easier to collide. Especially for names like `Core`. Reviewed By: WillerZ Differential Revision: D5460766 fbshipit-source-id: 3f7bff784bbb89c7c86d2f1824323d71321c7ad6
In-place construction for Future Summary: [Folly] In-place construction for `Future`. Using `in_place` as the first argument. Avoid constructing a contained object and then moving it into the `Future`, which may be more expensive, by providing an unambiguous way to specify perfect forwarding. And a matching overload of `makeFuture` for no particularly good reason. Differential Revision: D5362324 fbshipit-source-id: e612965f34ed0fae5fac17db631f7eab9984c696
Promise<T>::makeEmpty() and Future<T>::makeEmpty() Summary: [Folly] `Promise<T>::makeEmpty()` and `Future<T>::makeEmpty()`. These can currently be done by creating, and then moving away from, regular promises and futures. But that allocates; this is semantically equivalent but more efficient. Differential Revision: D5368339 fbshipit-source-id: de054cfc75c701c5d39aac64d9a2949cd34b1896
Content-conversion constructors for Future Summary: Allows you to construct a `Future<A>` from a `Future<B>` if A can be constructed from `B&&`. The constructor is `implicit` if and only if `B&&` is convertible to `A`. This is the same philosophy as Optional, and has the same use-cases. Reviewed By: yfeldblum Differential Revision: D5264185 fbshipit-source-id: e2fae373ab549c186a69dc5f4e32481ef7b11bba