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

Revert D15300706: defer inline behaviour

Reviewed By: yfeldblum

Differential Revision: D16639497

fbshipit-source-id: ddefeb12e2f83bc86e410092233efb2cdeaacbd0
parent 115fe40f
......@@ -823,7 +823,7 @@ SemiFuture<T>::defer(F&& func) && {
}
}();
auto sf = Future<T>(this->core_).thenTryInline(std::forward<F>(func)).semi();
auto sf = Future<T>(this->core_).thenTry(std::forward<F>(func)).semi();
this->core_ = nullptr;
// Carry deferred executor through chain as constructor from Future will
// nullify it
......@@ -849,9 +849,9 @@ SemiFuture<T>::deferExTry(F&& func) && {
}();
auto sf = Future<T>(this->core_)
.thenExTryInline([func = std::forward<F>(func)](
folly::Executor::KeepAlive<>&& keepAlive,
folly::Try<T>&& val) mutable {
.thenExTry([func = std::forward<F>(func)](
folly::Executor::KeepAlive<>&& keepAlive,
folly::Try<T>&& val) mutable {
return std::forward<F>(func)(
std::move(keepAlive), std::forward<decltype(val)>(val));
})
......
......@@ -666,11 +666,6 @@ class SemiFuture : private futures::detail::FutureBase<T> {
/// support all executors would boost block and we would simply use some form
/// of driveable executor here.
///
/// All forms of defer will run the continuation inline with the execution of
/// the previous callback in the chain if the callback attached to the
/// previous future that triggers execution of func runs on the same executor
/// that func would be executed on.
///
/// Preconditions:
///
/// - `valid() == true` (else throws FutureInvalid)
......@@ -695,11 +690,6 @@ class SemiFuture : private futures::detail::FutureBase<T> {
/// Defer for functions taking a T rather than a Try<T>.
///
/// All forms of defer will run the continuation inline with the execution of
/// the previous callback in the chain if the callback attached to the
/// previous future that triggers execution of func runs on the same executor
/// that func would be executed on.
///
/// Preconditions:
///
/// - `valid() == true` (else throws FutureInvalid)
......
......@@ -249,8 +249,7 @@ TEST(Via, then2) {
TEST(Via, allowInline) {
ManualExecutor x1, x2;
bool a = false, b = false, c = false, d = false, e = false, f = false,
g = false, h = false, i = false, j = false, k = false, l = false,
m = false, n = false, o = false, p = false, q = false, r = false;
g = false, h = false, i = false, j = false, k = false, l = false;
via(&x1)
.thenValue([&](auto&&) { a = true; })
.thenTryInline([&](auto&&) { b = true; })
......@@ -270,19 +269,7 @@ TEST(Via, allowInline) {
.semi()
.deferValue([&](auto&&) { k = true; })
.via(&x2)
.thenValueInline([&](auto&&) { l = true; })
.semi()
.deferValue([&](auto&&) { m = true; })
.via(&x1)
.thenValue([&](auto&&) { n = true; })
.semi()
.deferValue([&](auto&&) { o = true; })
.deferValue([&](auto&&) { p = true; })
.via(&x1)
.semi()
.deferValue([&](auto&&) { q = true; })
.deferValue([&](auto&&) { r = true; })
.via(&x2);
.thenValueInline([&](auto&&) { l = true; });
EXPECT_FALSE(a);
EXPECT_FALSE(b);
......@@ -324,31 +311,16 @@ TEST(Via, allowInline) {
EXPECT_TRUE(i);
EXPECT_FALSE(j);
// Defer should run on x1 and therefore not inline
// Subsequent deferred work is run on x1 and hence not inlined.
// Deferred work is not inline so k will remain false
x2.run();
EXPECT_TRUE(j);
EXPECT_TRUE(k);
EXPECT_TRUE(l);
EXPECT_FALSE(m);
// Complete the deferred task
x1.run();
EXPECT_TRUE(m);
EXPECT_FALSE(n);
// Here defer and the above thenValue are both on x1, defer should be
// inline
x1.run();
EXPECT_TRUE(n);
EXPECT_TRUE(o);
EXPECT_TRUE(p);
EXPECT_FALSE(q);
EXPECT_FALSE(k);
// Change of executor in deferred executor so now run x2 to complete
// Deferred work is not inline, but subsequent inline work should be inlined
// consistently with deferred work.
x2.run();
EXPECT_TRUE(q);
EXPECT_TRUE(r);
EXPECT_TRUE(k);
EXPECT_TRUE(l);
}
#ifndef __APPLE__ // TODO #7372389
......
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