From 0651f3c7b63130842e85d44fec624b82a33b67a3 Mon Sep 17 00:00:00 2001 From: Spencer T Brody Date: Wed, 8 Apr 2020 21:24:21 +0000 Subject: SERVER-43442 Remove blocking call from AsyncWorkScheduler host targetting Also updates some places relying on implicit conversion from Status to Future to be explicit. --- src/mongo/util/future.h | 9 +++++++++ src/mongo/util/future_util.h | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src/mongo/util') diff --git a/src/mongo/util/future.h b/src/mongo/util/future.h index 29ec737e8cc..89c97fa3d42 100644 --- a/src/mongo/util/future.h +++ b/src/mongo/util/future.h @@ -797,6 +797,15 @@ public: }); } + /** + * Same as setFrom(Future) above, but takes a SemiFuture instead of a Future. + */ + void setFrom(SemiFuture&& future) noexcept { + setImpl([&](boost::intrusive_ptr>&& sharedState) { + std::move(future).propagateResultTo(sharedState.get()); + }); + } + TEMPLATE(typename... Args) REQUIRES(std::is_constructible_v || (std::is_void_v && sizeof...(Args) == 0)) void emplaceValue(Args&&... args) noexcept { diff --git a/src/mongo/util/future_util.h b/src/mongo/util/future_util.h index c69c376bbee..6c1d71ac134 100644 --- a/src/mongo/util/future_util.h +++ b/src/mongo/util/future_util.h @@ -42,7 +42,11 @@ ExecutorFuture sleepUntil(std::shared_ptr executor auto scheduledWorkHandle = executor->scheduleWorkAt( date, [taskCompletionPromise](const executor::TaskExecutor::CallbackArgs& args) mutable { - taskCompletionPromise->setFrom(args.status); + if (args.status.isOK()) { + taskCompletionPromise->emplaceValue(); + } else { + taskCompletionPromise->setError(args.status); + } }); if (!scheduledWorkHandle.isOK()) { -- cgit v1.2.1