Future API for CacheClientCommon
[folly.git] / folly / wangle / Promise-inl.h
index 6e7e4947530450c5e1b73055170abff7dd671e4a..490602702eec74686ede50ee993e10433aa74267 100644 (file)
@@ -124,8 +124,8 @@ void Promise<T>::setValue() {
 
 template <class T>
 template <class F>
-void Promise<T>::fulfil(const F& func) {
-  fulfilHelper(func);
+void Promise<T>::fulfil(F&& func) {
+  fulfilHelper(std::forward<F>(func));
 }
 
 template <class T>
@@ -133,7 +133,7 @@ template <class F>
 typename std::enable_if<
   std::is_convertible<typename std::result_of<F()>::type, T>::value &&
   !std::is_same<T, void>::value>::type
-inline Promise<T>::fulfilHelper(const F& func) {
+inline Promise<T>::fulfilHelper(F&& func) {
   throwIfFulfilled();
   try {
     setValue(func());
@@ -147,7 +147,7 @@ template <class F>
 typename std::enable_if<
   std::is_same<typename std::result_of<F()>::type, void>::value &&
   std::is_same<T, void>::value>::type
-inline Promise<T>::fulfilHelper(const F& func) {
+inline Promise<T>::fulfilHelper(F&& func) {
   throwIfFulfilled();
   try {
     func();