24#include <seastar/core/coroutine.hh>
30template <
bool CheckPreempt,
typename T>
31class [[nodiscard]] as_future_awaiter {
37 as_future_awaiter(
const as_future_awaiter&) =
delete;
38 as_future_awaiter(as_future_awaiter&&) =
delete;
40 bool await_ready() const noexcept {
41 return _future.
available() && (!CheckPreempt || !need_preempt());
45 void await_suspend(std::coroutine_handle<U> hndl)
noexcept {
46 if (!CheckPreempt || !_future.available()) {
47 _future.set_coroutine(hndl.promise());
49 schedule(&hndl.promise());
54 return std::move(_future);
85template<
typename T =
void>
86class [[nodiscard]]
as_future :
public seastar::internal::as_future_awaiter<true, T> {
98template<
typename T =
void>
co_await:s a future, returning it as result, without checking if preemption is needed.
Definition: as_future.hh:99
co_await:s a future, returning it as result.
Definition: as_future.hh:86
A representation of a possibly not-yet-computed value.
Definition: future.hh:1240
bool available() const noexcept
Checks whether the future is available.
Definition: future.hh:1394
Seastar API namespace.
Definition: abort_on_ebadf.hh:26