then-with-Executor
[folly.git] / folly / futures / Future-inl.h
index 7a2ffc2b3263351118babc339109faff788af01a..94930b7b965125e05dddb2cd0b0f423b7a51471f 100644 (file)
@@ -235,6 +235,16 @@ Future<T>::then(R(Caller::*func)(Args...), Caller *instance) {
   });
 }
 
+template <class T>
+template <class... Args>
+auto Future<T>::then(Executor* x, Args&&... args)
+  -> decltype(this->then(std::forward<Args>(args)...))
+{
+  auto oldX = getExecutor();
+  setExecutor(x);
+  return this->then(std::forward<Args>(args)...).via(oldX);
+}
+
 template <class T>
 Future<void> Future<T>::then() {
   return then([] (Try<T>&& t) {});