/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <folly/Portability.h>
#include <folly/futures/DrivableExecutor.h>
#include <folly/futures/Promise.h>
-#include <folly/futures/Try.h>
+#include <folly/Try.h>
#include <folly/futures/FutureException.h>
#include <folly/futures/detail/Types.h>
Future(Future&&) noexcept;
Future& operator=(Future&&) noexcept;
- // conversion constructors
- template <
- class U,
- typename = typename std::enable_if<std::is_convertible<U, T>::value &&
- sizeof(U) == sizeof(T)>::type>
- /* implicit */ Future(Future<U>&&) noexcept;
- template <
- class U,
- typename = typename std::enable_if<std::is_convertible<U, T>::value &&
- sizeof(U) == sizeof(T)>::type>
- /* implicit */ Future& operator=(Future<U>&&) noexcept;
-
/// Construct a Future from a value (perfect forwarding)
template <class T2 = T, typename =
typename std::enable_if<
!isFuture<typename std::decay<T2>::type>::value>::type>
/* implicit */ Future(T2&& val);
- template <class T2 = T, typename =
- typename std::enable_if<
- std::is_same<Unit, T2>::value>::type>
- Future();
+ template <class T2 = T>
+ /* implicit */ Future(
+ typename std::enable_if<std::is_same<Unit, T2>::value>::type* = nullptr);
~Future();
/** A reference to the Try of the value */
Try<T>& getTry();
+ /// Call e->drive() repeatedly until the future is fulfilled. Examples
+ /// of DrivableExecutor include EventBase and ManualExecutor. Returns a
+ /// reference to the Try of the value.
+ Try<T>& getTryVia(DrivableExecutor* e);
+
/// If the promise has been fulfilled, return an Optional with the Try<T>.
/// Otherwise return an empty Optional.
/// Note that this moves the Try<T> out.
template <class E>
void raise(E&& exception) {
raise(make_exception_wrapper<typename std::remove_reference<E>::type>(
- std::move(exception)));
+ std::forward<E>(exception)));
}
/// Raise an interrupt. If the promise holder has an interrupt