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

Future::then to Future::thenValue

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

Reviewed By: Orvid

Differential Revision: D10362133

fbshipit-source-id: e638d24e95c5c6c46d0366eabcd1ff9537421bc6
parent fec6b413
......@@ -255,7 +255,8 @@ TEST(Executor, Runnable) {
TEST(Executor, ThrowableThen) {
InlineExecutor x;
auto f = Future<Unit>().then([]() { throw std::runtime_error("Faildog"); });
auto f = Future<Unit>().thenValue(
[](auto&&) { throw std::runtime_error("Faildog"); });
/*
auto f = Future<Unit>().via(&x).then([](){
......@@ -295,7 +296,7 @@ TEST(Executor, DoNothingExecutor) {
DoNothingExecutor x;
// Submit future callback to DoNothingExecutor
auto f = folly::via(&x).then([] { return 42; });
auto f = folly::via(&x).thenValue([](auto&&) { return 42; });
// Callback function is stored in DoNothingExecutor, but not executed.
EXPECT_FALSE(f.isReady());
......
......@@ -648,11 +648,11 @@ static void removeThreadTest() {
TPE fe(2);
f = folly::makeFuture()
.via(&fe)
.then([&id1]() {
.thenValue([&id1](auto&&) {
burnMs(100)();
id1 = std::this_thread::get_id();
})
.then([&id2]() {
.thenValue([&id2](auto&&) {
return 77;
id2 = std::this_thread::get_id();
});
......@@ -708,11 +708,11 @@ template <typename TPE>
void keepAliveTest() {
auto executor = std::make_unique<TPE>(4);
auto f =
futures::sleep(std::chrono::milliseconds{100})
.via(executor.get())
.then([keepAlive = getKeepAliveToken(executor.get())] { return 42; })
.semi();
auto f = futures::sleep(std::chrono::milliseconds{100})
.via(executor.get())
.thenValue([keepAlive = getKeepAliveToken(executor.get())](
auto&&) { return 42; })
.semi();
executor.reset();
......@@ -831,11 +831,11 @@ static void WeakRefTest() {
TPE fe(1);
f = folly::makeFuture()
.via(&fe)
.then([]() { burnMs(100)(); })
.then([&] { ++counter; })
.thenValue([](auto&&) { burnMs(100)(); })
.thenValue([&](auto&&) { ++counter; })
.via(fe.weakRef())
.then([]() { burnMs(100)(); })
.then([&] { ++counter; });
.thenValue([](auto&&) { burnMs(100)(); })
.thenValue([&](auto&&) { ++counter; });
}
EXPECT_THROW(std::move(*f).get(), folly::BrokenPromise);
EXPECT_EQ(1, counter);
......@@ -853,12 +853,12 @@ static void virtualExecutorTest() {
VirtualExecutor ve(fe);
f = futures::sleep(100ms)
.via(&ve)
.then([&] {
.thenValue([&](auto&&) {
++counter;
return futures::sleep(100ms);
})
.via(&fe)
.then([&] { ++counter; })
.thenValue([&](auto&&) { ++counter; })
.semi();
}
EXPECT_EQ(1, counter);
......
......@@ -123,7 +123,7 @@ class FutureDAG : public std::enable_shared_from_this<FutureDAG> {
collect(dependencies)
.via(nodes[handle].executor)
.then([this, handle] {
.thenValue([this, handle](std::vector<Unit>&&) {
nodes[handle].func().then([this, handle](Try<Unit>&& t) {
nodes[handle].promise.setTry(std::move(t));
});
......@@ -134,8 +134,8 @@ class FutureDAG : public std::enable_shared_from_this<FutureDAG> {
}
nodes[sourceHandle].promise.setValue();
return nodes[sinkHandle].promise.getFuture().then(
[that = shared_from_this(), sourceHandle, sinkHandle]() {
return nodes[sinkHandle].promise.getFuture().thenValue(
[that = shared_from_this(), sourceHandle, sinkHandle](Unit) {
that->clean_state(sourceHandle, sinkHandle);
});
}
......
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