Commit 8d639495 authored by Song Zhou's avatar Song Zhou Committed by Facebook Github Bot

Make folly::collectAnyWithoutException return a SemiFuture

Reviewed By: yfeldblum

Differential Revision: D10851133

fbshipit-source-id: 72493988c4d32011b1ee76af7191d3bbe5fe43b2
parent 6e5ef0b1
...@@ -1654,9 +1654,8 @@ collectAny(InputIterator first, InputIterator last) { ...@@ -1654,9 +1654,8 @@ collectAny(InputIterator first, InputIterator last) {
// collectAnyWithoutException (iterator) // collectAnyWithoutException (iterator)
// TODO(T26439406): Make return SemiFuture
template <class InputIterator> template <class InputIterator>
Future<std::pair< SemiFuture<std::pair<
size_t, size_t,
typename std::iterator_traits<InputIterator>::value_type::value_type>> typename std::iterator_traits<InputIterator>::value_type::value_type>>
collectAnyWithoutException(InputIterator first, InputIterator last) { collectAnyWithoutException(InputIterator first, InputIterator last) {
...@@ -1684,7 +1683,7 @@ collectAnyWithoutException(InputIterator first, InputIterator last) { ...@@ -1684,7 +1683,7 @@ collectAnyWithoutException(InputIterator first, InputIterator last) {
} }
}); });
} }
return ctx->p.getSemiFuture().via(&InlineExecutor::instance()); return ctx->p.getSemiFuture();
} }
// collectN (iterator) // collectN (iterator)
......
...@@ -375,7 +375,7 @@ auto collectAny(Collection&& c) -> decltype(collectAny(c.begin(), c.end())) { ...@@ -375,7 +375,7 @@ auto collectAny(Collection&& c) -> decltype(collectAny(c.begin(), c.end())) {
* excpetions, the last exception will be returned as a result. * excpetions, the last exception will be returned as a result.
*/ */
template <class InputIterator> template <class InputIterator>
Future<std::pair< SemiFuture<std::pair<
size_t, size_t,
typename std::iterator_traits<InputIterator>::value_type::value_type>> typename std::iterator_traits<InputIterator>::value_type::value_type>>
collectAnyWithoutException(InputIterator first, InputIterator last); collectAnyWithoutException(InputIterator first, InputIterator last);
......
...@@ -343,6 +343,8 @@ TEST(Collect, collectAny) { ...@@ -343,6 +343,8 @@ TEST(Collect, collectAny) {
} }
TEST(Collect, collectAnyWithoutException) { TEST(Collect, collectAnyWithoutException) {
auto& executor = folly::InlineExecutor::instance();
{ {
std::vector<Promise<int>> promises(10); std::vector<Promise<int>> promises(10);
std::vector<Future<int>> futures; std::vector<Future<int>> futures;
...@@ -351,7 +353,7 @@ TEST(Collect, collectAnyWithoutException) { ...@@ -351,7 +353,7 @@ TEST(Collect, collectAnyWithoutException) {
futures.push_back(p.getFuture()); futures.push_back(p.getFuture());
} }
auto onef = collectAnyWithoutException(futures); auto onef = collectAnyWithoutException(futures).via(&executor);
/* futures were moved in, so these are invalid now */ /* futures were moved in, so these are invalid now */
EXPECT_FALSE(onef.isReady()); EXPECT_FALSE(onef.isReady());
...@@ -372,7 +374,7 @@ TEST(Collect, collectAnyWithoutException) { ...@@ -372,7 +374,7 @@ TEST(Collect, collectAnyWithoutException) {
futures.push_back(p.getFuture()); futures.push_back(p.getFuture());
} }
auto onef = collectAnyWithoutException(futures); auto onef = collectAnyWithoutException(futures).via(&executor);
EXPECT_FALSE(onef.isReady()); EXPECT_FALSE(onef.isReady());
...@@ -396,7 +398,7 @@ TEST(Collect, collectAnyWithoutException) { ...@@ -396,7 +398,7 @@ TEST(Collect, collectAnyWithoutException) {
futures.push_back(p.getFuture()); futures.push_back(p.getFuture());
} }
auto onef = collectAnyWithoutException(futures); auto onef = collectAnyWithoutException(futures).via(&executor);
EXPECT_FALSE(onef.isReady()); EXPECT_FALSE(onef.isReady());
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
......
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