93 requires std::is_invocable_r_v<result<T>,
W&, std::optional<std::chrono::milliseconds>>
111 template<
typename W,
typename D>
112 requires std::is_invocable_r_v<result<T>,
W&, std::optional<std::chrono::milliseconds>> &&
113 std::is_nothrow_invocable_r_v<bool, const D&>
134#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
159 template<
typename Rep,
typename Period>
184 template<
typename Rep,
typename Period>
190 std::move_only_function<result<T>(std::optional<std::chrono::milliseconds>)>
waiter;
197 template<
typename W,
typename D>
199 : waiter(std::forward<W>(w))
200 , done_check(std::forward<D>(d)) {}
204 std::shared_ptr<state> _state;
212 if (_state->done_check) {
213 return _state->done_check();
215 auto r = _state->waiter(std::optional<std::chrono::milliseconds>{std::chrono::milliseconds{0}});
216 return r.has_value();
222 if constexpr (std::is_void_v<T>) {
228 return _state->waiter(std::nullopt);
232template<
typename Rep,
typename Period>
235 if constexpr (std::is_void_v<T>) {
241 return _state->waiter(
242 std::optional<std::chrono::milliseconds>{std::chrono::ceil<std::chrono::milliseconds>(
timeout)}
future(W waiter, D done_check)
Constructs a future with an explicit non-blocking done-check.
future(W waiter)
Constructs a future from a waiter callable.
bool valid() const noexcept
Returns whether this future is associated with an async operation.
T wait() const
Blocks until the operation completes.
result< T > try_wait_for(const std::chrono::duration< Rep, Period > &timeout) const
Blocks until the operation completes or the timeout expires.
result< T > try_wait() const
Blocks until the operation completes.
T wait_for(const std::chrono::duration< Rep, Period > &timeout) const
Blocks until the operation completes or the timeout expires.
future()=default
Constructs an invalid (detached) future.
bool done() const noexcept
Non-blocking check for whether the operation has completed.
T unwrap(result< T > result)
Throws a std::system_error if the result is an error.
@ timeout
Operation timed out.
std::expected< T, std::error_code > result
result type wrapping a value or error code.