Commit 955ae9ac authored by octal's avatar octal

Promise::then now returns a new Promise so that chaining now becomes easier

parent 5455a471
This diff is collapsed.
...@@ -30,6 +30,7 @@ TEST(async_test, basic_test) { ...@@ -30,6 +30,7 @@ TEST(async_test, basic_test) {
p1.then([&](int v) { val = v; }, Async::NoExcept); p1.then([&](int v) { val = v; }, Async::NoExcept);
ASSERT_EQ(val, 10); ASSERT_EQ(val, 10);
{ {
Async::Promise<int> p2 = doAsync(10); Async::Promise<int> p2 = doAsync(10);
p2.then([](int result) { ASSERT_EQ(result, 20); }, p2.then([](int result) { ASSERT_EQ(result, 20); },
...@@ -58,7 +59,6 @@ TEST(async_test, chain_test) { ...@@ -58,7 +59,6 @@ TEST(async_test, chain_test) {
p1 p1
.then([](int result) { return result * 2; }, Async::NoExcept) .then([](int result) { return result * 2; }, Async::NoExcept)
->chain()
.then([](int result) { std::cout << "Result = " << result << std::endl; }, .then([](int result) { std::cout << "Result = " << result << std::endl; },
Async::NoExcept); Async::NoExcept);
...@@ -67,13 +67,10 @@ TEST(async_test, chain_test) { ...@@ -67,13 +67,10 @@ TEST(async_test, chain_test) {
resolve(10); resolve(10);
}); });
#if 0
p2 p2
.then([](int result) { return result * 2.0; }, Async::IgnoreException) .then([](int result) { return result * 2.2901; }, Async::IgnoreException)
->chain()
.then([](double result) { std::cout << "Result = " << result << std::endl; }, .then([](double result) { std::cout << "Result = " << result << std::endl; },
Async::IgnoreException); Async::IgnoreException);
#endif
} }
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