Commit c19c06e5 authored by Lee Howes's avatar Lee Howes Committed by Facebook GitHub Bot

Remove collectAnyUnsafe

Summary:
Remove the Future-returning form of collectAny completely.

(Note: this ignores all push blocking failures!)

Reviewed By: yfeldblum

Differential Revision: D22345361

fbshipit-source-id: 180bb74c8f64052de372f5d982ad4e77cbff0119
parent 6b01128d
......@@ -1596,14 +1596,6 @@ Future<std::tuple<typename remove_cvref_t<Fs>::value_type...>> collectUnsafe(
// collectAny (iterator)
template <class InputIterator>
Future<std::pair<
size_t,
Try<typename std::iterator_traits<InputIterator>::value_type::value_type>>>
collectAnyUnsafe(InputIterator first, InputIterator last) {
return collectAny(first, last).toUnsafeFuture();
}
template <class InputIterator>
SemiFuture<std::pair<
size_t,
......
......@@ -2462,25 +2462,12 @@ SemiFuture<std::pair<
size_t,
Try<typename std::iterator_traits<InputIterator>::value_type::value_type>>>
collectAny(InputIterator first, InputIterator last);
// Unsafe variant of collectAny, Returns a Future that completes inline.
template <class InputIterator>
Future<std::pair<
size_t,
Try<typename std::iterator_traits<InputIterator>::value_type::value_type>>>
collectAnyUnsafe(InputIterator first, InputIterator last);
/// Sugar for the most common case
template <class Collection>
auto collectAny(Collection&& c) -> decltype(collectAny(c.begin(), c.end())) {
return collectAny(c.begin(), c.end());
}
// Unsafe variant of common form of collectAny, Returns a Future that completes
// inline.
template <class Collection>
auto collectAnyUnsafe(Collection&& c)
-> decltype(collectAnyUnsafe(c.begin(), c.end())) {
return collectAnyUnsafe(c.begin(), c.end());
}
/** Similar to collectAny, collectAnyWithoutException return the first Future to
* complete without exceptions. If none of the future complete without
......
......@@ -444,33 +444,6 @@ TEST(Collect, collectAny) {
auto& f = idx_fut.second;
EXPECT_EQ(42, f.value());
}
{
std::vector<Promise<int>> promises(10);
std::vector<Future<int>> futures;
for (auto& p : promises) {
futures.push_back(p.getFuture());
}
for (auto& f : futures) {
EXPECT_FALSE(f.isReady());
}
auto anyf = collectAnyUnsafe(futures);
/* futures were moved in, so these are invalid now */
EXPECT_FALSE(anyf.isReady());
promises[7].setValue(42);
EXPECT_TRUE(anyf.isReady());
auto& idx_fut = anyf.value();
auto i = idx_fut.first;
EXPECT_EQ(7, i);
auto& f = idx_fut.second;
EXPECT_EQ(42, f.value());
}
{
std::vector<Promise<int>> promises(10);
std::vector<SemiFuture<int>> futures;
......@@ -520,22 +493,6 @@ TEST(Collect, collectAny) {
EXPECT_TRUE(anyf.isReady());
EXPECT_TRUE(anyf.value().second.hasException());
}
// thenValue()
{
std::vector<Promise<int>> promises(10);
std::vector<Future<int>> futures;
for (auto& p : promises) {
futures.push_back(p.getFuture());
}
auto anyf = collectAnyUnsafe(futures).thenValue(
[](std::pair<size_t, Try<int>> p) { EXPECT_EQ(42, p.second.value()); });
promises[3].setValue(42);
EXPECT_TRUE(anyf.isReady());
}
}
TEST(Collect, collectAnyWithoutException) {
......
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