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

Remove thenMultiWithExecutor

Summary: Another overload that is not really necessary and adds complication. Removing to simplify.

Reviewed By: yfeldblum

Differential Revision: D15109455

fbshipit-source-id: 4312aab817d9796358e0b659c50c6e8f9d9ccb4e
parent 668cb0bb
......@@ -1801,49 +1801,6 @@ class Future : private futures::detail::FutureBase<T> {
return std::move(*this).thenMulti(std::forward<Callback>(fn));
}
/// Create a Future chain from a sequence of callbacks. i.e.
///
/// f.via(executor).then(a).then(b).then(c).via(oldExecutor)
///
/// where f is a Future<A> and the result of the chain is a Future<D>
/// becomes
///
/// std::move(f).thenMultiWithExecutor(executor, a, b, c);
///
/// Preconditions:
///
/// - `valid() == true` (else throws FutureInvalid)
///
/// Postconditions:
///
/// - Calling code should act as if `valid() == false`,
/// i.e., as if `*this` was moved into RESULT.
/// - `RESULT.valid() == true`
template <class Callback, class... Callbacks>
auto thenMultiWithExecutor(
Executor::KeepAlive<> x,
Callback&& fn,
Callbacks&&... fns) && {
// thenMultiExecutor with two callbacks is
// via(x).then(a).thenMulti(b, ...).via(oldX)
auto oldX = getKeepAliveToken(this->getExecutor());
this->setExecutor(std::move(x));
// TODO(T29171940): Switch to thenImplementation here. It is ambiguous
// as then used to be but that is better than keeping then in the public
// API.
using R = futures::detail::callableResult<T, decltype(fn)>;
return std::move(*this)
.thenImplementation(std::forward<Callback>(fn), R{})
.thenMulti(std::forward<Callbacks>(fns)...)
.via(std::move(oldX));
}
template <class Callback>
auto thenMultiWithExecutor(Executor::KeepAlive<> x, Callback&& fn) && {
// thenMulti with one callback is just a then with an executor
return std::move(*this).then(std::move(x), std::forward<Callback>(fn));
}
/// Moves-out `*this`, creating/returning a corresponding SemiFuture.
/// Result will behave like `*this` except result won't have an Executor.
///
......
......@@ -240,38 +240,6 @@ TEST(Via, priority) {
EXPECT_EQ(3, exe.count2);
}
TEST_F(ViaFixture, chainX1) {
EXPECT_EQ(
42,
makeFuture()
.thenMultiWithExecutor(eastExecutor.get(), [] { return 42; })
.get());
}
TEST_F(ViaFixture, chainX3) {
auto westThreadId = std::this_thread::get_id();
int count = 0;
auto f = via(westExecutor.get())
.thenMultiWithExecutor(
eastExecutor.get(),
[&] {
EXPECT_NE(std::this_thread::get_id(), westThreadId);
count++;
return 3.14159;
},
[&](double) {
count++;
return std::string("hello");
},
[&] { count++; })
.thenValue([&](auto&&) {
EXPECT_EQ(std::this_thread::get_id(), westThreadId);
return makeFuture(42);
});
EXPECT_EQ(42, f.getVia(waiter.get()));
EXPECT_EQ(3, count);
}
TEST(Via, then2) {
ManualExecutor x1, x2;
bool a = false, b = false, c = false;
......
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