Commit 439c7b22 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook GitHub Bot

Fix blockingWait to schedule task on the DrivableExecutor

Summary: The first portion of the task (before the first suspension point) was run inline.

Reviewed By: yfeldblum

Differential Revision: D21460275

fbshipit-source-id: 31d50e15d5890fbc7127dfff424a4e814dcb2320
parent 34ea33d2
...@@ -222,10 +222,11 @@ class BlockingWaitTask { ...@@ -222,10 +222,11 @@ class BlockingWaitTask {
folly::Try<detail::lift_lvalue_reference_t<T>> result; folly::Try<detail::lift_lvalue_reference_t<T>> result;
auto& promise = coro_.promise(); auto& promise = coro_.promise();
promise.setTry(&result); promise.setTry(&result);
{ executor->add(
RequestContextScopeGuard guard{RequestContext::saveContext()}; [coro = coro_, rctx = RequestContext::saveContext()]() mutable {
coro_.resume(); RequestContextScopeGuard guard{std::move(rctx)};
} coro.resume();
});
while (!promise.done()) { while (!promise.done()) {
executor->drive(); executor->drive();
} }
......
...@@ -255,8 +255,13 @@ TEST_F(BlockingWaitTest, WaitTaskInFiber) { ...@@ -255,8 +255,13 @@ TEST_F(BlockingWaitTest, WaitTaskInFiber) {
auto& fm = folly::fibers::getFiberManager(evb); auto& fm = folly::fibers::getFiberManager(evb);
auto future = fm.addTaskFuture([&] { auto future = fm.addTaskFuture([&] {
return folly::coro::blockingWait(folly::coro::co_invoke( return folly::coro::blockingWait(
[&]() -> folly::coro::Task<int> { co_return co_await promise; })); folly::coro::co_invoke([&]() -> folly::coro::Task<int> {
EXPECT_FALSE(folly::fibers::onFiber());
auto ret = co_await promise;
EXPECT_FALSE(folly::fibers::onFiber());
co_return ret;
}));
}); });
evb.loopOnce(); evb.loopOnce();
......
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