From: Yedidya Feldblum Date: Wed, 4 May 2016 04:32:23 +0000 (-0700) Subject: Let via take a functor by universal reference X-Git-Tag: 2016.07.26~288 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d0ed189073b29b342ea68e2371d498b7fcabb791;p=folly.git 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 --- diff --git a/folly/futures/Future-inl.h b/folly/futures/Future-inl.h index ed3aa434..aebe58b6 100644 --- a/folly/futures/Future-inl.h +++ b/folly/futures/Future-inl.h @@ -444,11 +444,11 @@ inline Future Future::via(Executor* executor, int8_t priority) & { } template -auto via(Executor* x, Func func) +auto via(Executor* x, Func&& func) -> Future::Inner> { // TODO make this actually more performant. :-P #7260175 - return via(x).then(std::move(func)); + return via(x).then(std::forward(func)); } template diff --git a/folly/futures/helpers.h b/folly/futures/helpers.h index bcfd8ba3..75f92537 100644 --- a/folly/futures/helpers.h +++ b/folly/futures/helpers.h @@ -147,7 +147,7 @@ inline Future via( /// This is semantically equivalent to via(executor).then(func), but /// easier to read and slightly more efficient. template -auto via(Executor*, Func func) +auto via(Executor*, Func&& func) -> Future::Inner>; /** When all the input Futures complete, the returned Future will complete.