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

Future::then to Future::thenValue in ThreadedExecutorTest

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

Reviewed By: Orvid

Differential Revision: D10346695

fbshipit-source-id: 7f9641ef5b7f93ac4376a52724d42502eb1703b9
parent eb5a6416
...@@ -29,8 +29,8 @@ class ThreadedExecutorTest : public testing::Test {}; ...@@ -29,8 +29,8 @@ class ThreadedExecutorTest : public testing::Test {};
TEST_F(ThreadedExecutorTest, example) { TEST_F(ThreadedExecutorTest, example) {
folly::ThreadedExecutor x; folly::ThreadedExecutor x;
auto ret = folly::via(&x) auto ret = folly::via(&x)
.then([&] { return 42; }) .thenValue([&](auto&&) { return 42; })
.then([&](int n) { return folly::to<std::string>(n); }) .thenValue([&](int n) { return folly::to<std::string>(n); })
.get(); .get();
EXPECT_EQ("42", ret); EXPECT_EQ("42", ret);
...@@ -54,9 +54,9 @@ TEST_F(ThreadedExecutorTest, many) { ...@@ -54,9 +54,9 @@ TEST_F(ThreadedExecutorTest, many) {
folly::collect( folly::collect(
folly::gen::range<size_t>(0, kNumTasks) | folly::gen::range<size_t>(0, kNumTasks) |
folly::gen::map([&](size_t i) { folly::gen::map([&](size_t i) {
return folly::via(&x).then([=] { return i; }).then([](size_t k) { return folly::via(&x)
return folly::to<std::string>(k); .thenValue([=](auto&&) { return i; })
}); .thenValue([](size_t k) { return folly::to<std::string>(k); });
}) | }) |
folly::gen::as<std::vector>()) folly::gen::as<std::vector>())
.get(); .get();
...@@ -73,11 +73,11 @@ TEST_F(ThreadedExecutorTest, many_sleeping_constant_time) { ...@@ -73,11 +73,11 @@ TEST_F(ThreadedExecutorTest, many_sleeping_constant_time) {
folly::gen::range<size_t>(0, kNumTasks) | folly::gen::range<size_t>(0, kNumTasks) |
folly::gen::map([&](size_t i) { folly::gen::map([&](size_t i) {
return folly::via(&x) return folly::via(&x)
.then([=] { .thenValue([=](auto&&) {
/* sleep override */ std::this_thread::sleep_for(kDelay); /* sleep override */ std::this_thread::sleep_for(kDelay);
}) })
.then([=] { return i; }) .thenValue([=](auto&&) { return i; })
.then([](size_t k) { return folly::to<std::string>(k); }); .thenValue([](size_t k) { return folly::to<std::string>(k); });
}) | }) |
folly::gen::as<std::vector>()) folly::gen::as<std::vector>())
.get(); .get();
...@@ -94,12 +94,12 @@ TEST_F(ThreadedExecutorTest, many_sleeping_decreasing_time) { ...@@ -94,12 +94,12 @@ TEST_F(ThreadedExecutorTest, many_sleeping_decreasing_time) {
folly::gen::range<size_t>(0, kNumTasks) | folly::gen::range<size_t>(0, kNumTasks) |
folly::gen::map([&](size_t i) { folly::gen::map([&](size_t i) {
return folly::via(&x) return folly::via(&x)
.then([=] { .thenValue([=](auto&&) {
auto delay = kDelay * (kNumTasks - i) / kNumTasks; auto delay = kDelay * (kNumTasks - i) / kNumTasks;
/* sleep override */ std::this_thread::sleep_for(delay); /* sleep override */ std::this_thread::sleep_for(delay);
}) })
.then([=] { return i; }) .thenValue([=](auto&&) { return i; })
.then([](size_t k) { return folly::to<std::string>(k); }); .thenValue([](size_t k) { return folly::to<std::string>(k); });
}) | }) |
folly::gen::as<std::vector>()) folly::gen::as<std::vector>())
.get(); .get();
......
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