Commit d0ed1890 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot 3

Let via take a functor by universal reference

Summary:
[Folly] Let `via` take a functor by universal reference.

And perfect-forward the functor to the call to `then`.

Reviewed By: fugalh

Differential Revision: D3255684

fb-gh-sync-id: 1b46a70fb9de88d21d785c0ce4d9dd3078829f13
fbshipit-source-id: 1b46a70fb9de88d21d785c0ce4d9dd3078829f13
parent f253e1e4
...@@ -444,11 +444,11 @@ inline Future<T> Future<T>::via(Executor* executor, int8_t priority) & { ...@@ -444,11 +444,11 @@ inline Future<T> Future<T>::via(Executor* executor, int8_t priority) & {
} }
template <class Func> template <class Func>
auto via(Executor* x, Func func) auto via(Executor* x, Func&& func)
-> Future<typename isFuture<decltype(func())>::Inner> -> Future<typename isFuture<decltype(func())>::Inner>
{ {
// TODO make this actually more performant. :-P #7260175 // TODO make this actually more performant. :-P #7260175
return via(x).then(std::move(func)); return via(x).then(std::forward<Func>(func));
} }
template <class T> template <class T>
......
...@@ -147,7 +147,7 @@ inline Future<Unit> via( ...@@ -147,7 +147,7 @@ inline Future<Unit> via(
/// This is semantically equivalent to via(executor).then(func), but /// This is semantically equivalent to via(executor).then(func), but
/// easier to read and slightly more efficient. /// easier to read and slightly more efficient.
template <class Func> template <class Func>
auto via(Executor*, Func func) auto via(Executor*, Func&& func)
-> Future<typename isFuture<decltype(func())>::Inner>; -> Future<typename isFuture<decltype(func())>::Inner>;
/** When all the input Futures complete, the returned Future will complete. /** When all the input Futures complete, the returned Future will complete.
......
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