template <class T>
bool FutureBase<T>::hasValue() {
- return getTry().hasValue();
+ return core_->getTry().hasValue();
}
template <class T>
bool FutureBase<T>::hasException() {
- return getTry().hasException();
+ return core_->getTry().hasException();
}
template <class T>
}
}
-template <class T>
-Try<T>& FutureBase<T>::getTry() {
- throwIfInvalid();
-
- return core_->getTry();
-}
-
template <class T>
void FutureBase<T>::throwIfInvalid() const {
if (!core_) {
}
}
+template <class T>
+Try<T> SemiFuture<T>::getTry() && {
+ wait();
+ return std::move(this->core_->getTry());
+}
+
template <class T>
Future<T>& Future<T>::wait() & {
futures::detail::waitImpl(*this);
}
}
+template <class T>
+Try<T>& Future<T>::getTry() {
+ throwIfInvalid();
+
+ return this->core_->getTry();
+}
+
template <class T>
T Future<T>::getVia(DrivableExecutor* e) {
return std::move(waitVia(e).value());
/// sugar for getTry().hasException()
bool hasException();
- /** A reference to the Try of the value */
- Try<T>& getTry();
-
/// 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.
/* implicit */ SemiFuture(Future<T>&&) noexcept;
using Base::cancel;
- using Base::getTry;
using Base::hasException;
using Base::hasValue;
using Base::isActive;
/// exception).
T get(Duration dur) &&;
+ /// Block until the future is fulfilled, or until timed out. Returns the
+ /// Try of the value (moved out).
+ Try<T> getTry() &&;
+
/// Block until this Future is complete. Returns a reference to this Future.
SemiFuture<T>& wait() &;
Future& operator=(Future<T2>&&);
using Base::cancel;
- using Base::getTry;
using Base::hasException;
using Base::hasValue;
using Base::isActive;
/// exception).
T get(Duration dur);
+ /** A reference to the Try of the value */
+ Try<T>& getTry();
+
/// Block until this Future is complete. Returns a reference to this Future.
Future<T>& wait() &;