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

Rename defer for an executor-taking continuation deferExTry for consistency with thenExTry

Summary: Renames defer taking an executor-taking continuation to deferExTry and modifying to take a KeepAlive for consistency with thenExTry.

Reviewed By: yfeldblum

Differential Revision: D14761230

fbshipit-source-id: af95afabb662197edcf2eeb432bc64c57011c776
parent dad6c2b8
...@@ -357,9 +357,10 @@ class FOLLY_NODISCARD Task { ...@@ -357,9 +357,10 @@ class FOLLY_NODISCARD Task {
} }
SemiFuture<folly::lift_unit_t<StorageType>> semi() && { SemiFuture<folly::lift_unit_t<StorageType>> semi() && {
return makeSemiFuture().defer( return makeSemiFuture().deferExTry(
[task = std::move(*this)](Executor* executor, Try<Unit>&&) mutable { [task = std::move(*this)](
return std::move(task).scheduleOn(executor).start(); const Executor::KeepAlive<>& executor, Try<Unit>&&) mutable {
return std::move(task).scheduleOn(executor.get()).start();
}); });
} }
......
...@@ -903,7 +903,7 @@ template <class T> ...@@ -903,7 +903,7 @@ template <class T>
template <typename F> template <typename F>
SemiFuture< SemiFuture<
typename futures::detail::tryExecutorCallableResult<T, F>::value_type> typename futures::detail::tryExecutorCallableResult<T, F>::value_type>
SemiFuture<T>::defer(F&& func) && { SemiFuture<T>::deferExTry(F&& func) && {
DeferredExecutor* deferredExecutor = getDeferredExecutor(); DeferredExecutor* deferredExecutor = getDeferredExecutor();
if (!deferredExecutor) { if (!deferredExecutor) {
auto newDeferredExecutor = DeferredExecutor::create(); auto newDeferredExecutor = DeferredExecutor::create();
......
...@@ -140,7 +140,8 @@ template < ...@@ -140,7 +140,8 @@ template <
typename F, typename F,
typename = std::enable_if_t<is_invocable<F, Executor*, Try<T>&&>::value>> typename = std::enable_if_t<is_invocable<F, Executor*, Try<T>&&>::value>>
struct tryExecutorCallableResult { struct tryExecutorCallableResult {
typedef detail::argResult<true, F, Executor*, Try<T>&&> Arg; typedef detail::argResult<true, F, const Executor::KeepAlive<>&, Try<T>&&>
Arg;
typedef isFutureOrSemiFuture<typename Arg::Result> ReturnsFuture; typedef isFutureOrSemiFuture<typename Arg::Result> ReturnsFuture;
typedef typename ReturnsFuture::Inner value_type; typedef typename ReturnsFuture::Inner value_type;
typedef Future<value_type> Return; typedef Future<value_type> Return;
......
...@@ -686,7 +686,7 @@ class SemiFuture : private futures::detail::FutureBase<T> { ...@@ -686,7 +686,7 @@ class SemiFuture : private futures::detail::FutureBase<T> {
template <typename F> template <typename F>
SemiFuture< SemiFuture<
typename futures::detail::tryExecutorCallableResult<T, F>::value_type> typename futures::detail::tryExecutorCallableResult<T, F>::value_type>
defer(F&& func) &&; deferExTry(F&& func) &&;
template <typename R, typename... Args> template <typename R, typename... Args>
auto defer(R (&func)(Args...)) && { auto defer(R (&func)(Args...)) && {
......
...@@ -1172,8 +1172,10 @@ TEST(SemiFuture, DeferWithNestedSemiFuture) { ...@@ -1172,8 +1172,10 @@ TEST(SemiFuture, DeferWithNestedSemiFuture) {
TEST(SemiFuture, DeferWithExecutor) { TEST(SemiFuture, DeferWithExecutor) {
ManualExecutor executor; ManualExecutor executor;
auto sf = makeSemiFuture().defer( auto sf = makeSemiFuture().deferExTry(
[&](Executor* e, Try<Unit>) { EXPECT_EQ(&executor, e); }); [&](const Executor::KeepAlive<>& e, Try<Unit>) {
EXPECT_EQ(&executor, e.get());
});
std::move(sf).via(&executor).getVia(&executor); std::move(sf).via(&executor).getVia(&executor);
} }
......
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