From d0ed189073b29b342ea68e2371d498b7fcabb791 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Tue, 3 May 2016 21:32:23 -0700 Subject: [PATCH] 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 --- folly/futures/Future-inl.h | 4 ++-- folly/futures/helpers.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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. -- 2.34.1