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

Use rvalue overload of Future::then in retrying

Summary:
Overall plan to modify Future<T>::then to be r-value qualified and use Future<T>::thenTry or Future<T>::thenValue.

The goal is to disambiguate folly::Future and to improve type and lifetime safety of Future and its methods.

Reviewed By: yfeldblum

Differential Revision: D9273440

fbshipit-source-id: f1e1b91fd8fe02020a5919b9193644e256413982
parent 9a1abfca
......@@ -84,21 +84,21 @@ void retryingImpl(size_t k, Policy&& p, FF&& ff, Prom prom) {
using F = invoke_result_t<FF, size_t>;
using T = typename F::value_type;
auto f = makeFutureWith([&] { return ff(k++); });
f.then([k,
prom = std::move(prom),
pm = std::forward<Policy>(p),
ffm = std::forward<FF>(ff)](Try<T>&& t) mutable {
std::move(f).then([k,
prom = std::move(prom),
pm = std::forward<Policy>(p),
ffm = std::forward<FF>(ff)](Try<T>&& t) mutable {
if (t.hasValue()) {
prom.setValue(std::move(t).value());
return;
}
auto& x = t.exception();
auto q = makeFutureWith([&] { return pm(k, x); });
q.then([k,
prom = std::move(prom),
xm = std::move(x),
pm = std::move(pm),
ffm = std::move(ffm)](Try<bool> shouldRetry) mutable {
std::move(q).then([k,
prom = std::move(prom),
xm = std::move(x),
pm = std::move(pm),
ffm = std::move(ffm)](Try<bool> shouldRetry) mutable {
if (shouldRetry.hasValue() && shouldRetry.value()) {
retryingImpl(k, std::move(pm), std::move(ffm), std::move(prom));
} else if (shouldRetry.hasValue()) {
......
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