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

Remaining nullary continuation fixes for folly

Summary: then to thenValue to remove calls to deprecated functions.

Reviewed By: yfeldblum

Differential Revision: D10366311

fbshipit-source-id: 99c4cd8bcfa2d9db80c2d8eb22300d92609a36fc
parent af21e4d6
...@@ -91,8 +91,10 @@ class TimedWaitAwaitable { ...@@ -91,8 +91,10 @@ class TimedWaitAwaitable {
bool await_suspend(std::experimental::coroutine_handle<> ch) { bool await_suspend(std::experimental::coroutine_handle<> ch) {
auto sharedState = std::make_shared<SharedState>(ch, storage_); auto sharedState = std::make_shared<SharedState>(ch, storage_);
waitAndNotify(std::move(awaitable_), sharedState).detach(); waitAndNotify(std::move(awaitable_), sharedState).detach();
futures::sleep(duration_).then( futures::sleep(duration_).thenValue(
[sharedState = std::move(sharedState)] { sharedState->setTimeout(); }); [sharedState = std::move(sharedState)](Unit) {
sharedState->setTimeout();
});
return true; return true;
} }
......
...@@ -197,7 +197,9 @@ TEST(Coro, CurrentExecutor) { ...@@ -197,7 +197,9 @@ TEST(Coro, CurrentExecutor) {
coro::Task<void> taskTimedWait() { coro::Task<void> taskTimedWait() {
auto fastFuture = auto fastFuture =
futures::sleep(std::chrono::milliseconds{50}).then([] { return 42; }); futures::sleep(std::chrono::milliseconds{50}).thenValue([](Unit) {
return 42;
});
auto fastResult = co_await coro::timed_wait( auto fastResult = co_await coro::timed_wait(
std::move(fastFuture), std::chrono::milliseconds{100}); std::move(fastFuture), std::chrono::milliseconds{100});
EXPECT_TRUE(fastResult); EXPECT_TRUE(fastResult);
...@@ -207,16 +209,19 @@ coro::Task<void> taskTimedWait() { ...@@ -207,16 +209,19 @@ coro::Task<void> taskTimedWait() {
ExpectedException() : std::runtime_error("ExpectedException") {} ExpectedException() : std::runtime_error("ExpectedException") {}
}; };
auto throwingFuture = futures::sleep(std::chrono::milliseconds{50}).then([] { auto throwingFuture =
throw ExpectedException(); futures::sleep(std::chrono::milliseconds{50}).thenValue([](Unit) {
}); throw ExpectedException();
});
EXPECT_THROW( EXPECT_THROW(
(void)co_await coro::timed_wait( (void)co_await coro::timed_wait(
std::move(throwingFuture), std::chrono::milliseconds{100}), std::move(throwingFuture), std::chrono::milliseconds{100}),
ExpectedException); ExpectedException);
auto slowFuture = auto slowFuture =
futures::sleep(std::chrono::milliseconds{200}).then([] { return 42; }); futures::sleep(std::chrono::milliseconds{200}).thenValue([](Unit) {
return 42;
});
auto slowResult = co_await coro::timed_wait( auto slowResult = co_await coro::timed_wait(
std::move(slowFuture), std::chrono::milliseconds{100}); std::move(slowFuture), std::chrono::milliseconds{100});
EXPECT_FALSE(slowResult); EXPECT_FALSE(slowResult);
......
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