Commit 618523a5 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Let Future::ensure and Future::onTimeout invoke forwarded

Summary: [Folly] Let `Future::ensure` and `Future::onTimeout` invoke forwarded callbacks, just as `Future::then` and other callbacks are invoked.

Reviewed By: LeeHowes

Differential Revision: D7722762

fbshipit-source-id: 52b5fb6a9247d99718de808b0d28abba7dacdbd6
parent 34371148
......@@ -1014,8 +1014,8 @@ Future<T>::onError(F&& func) {
template <class T>
template <class F>
Future<T> Future<T>::ensure(F&& func) {
return this->then([funcw = std::forward<F>(func)](Try<T> && t) mutable {
std::move(funcw)();
return this->then([funcw = std::forward<F>(func)](Try<T>&& t) mutable {
std::forward<F>(funcw)();
return makeFuture(std::move(t));
});
}
......@@ -1023,8 +1023,10 @@ Future<T> Future<T>::ensure(F&& func) {
template <class T>
template <class F>
Future<T> Future<T>::onTimeout(Duration dur, F&& func, Timekeeper* tk) {
return within(dur, tk).onError([funcw = std::forward<F>(func)](
TimedOut const&) { return std::move(funcw)(); });
return within(dur, tk).onError(
[funcw = std::forward<F>(func)](TimedOut const&) mutable {
return std::forward<F>(funcw)();
});
}
template <class T>
......
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