Seastar
High performance C++ framework for concurrent servers
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Public Member Functions | List of all members
seastar::coroutine::as_future< T > Class Template Reference

Detailed Description

template<typename T = void>
class seastar::coroutine::as_future< T >

co_await:s a future, returning it as result.

Similar to seastar::future::then_wrapped, coroutine::as_future waits for the future to resolve either to a ready future or to an exceptional one. It then returns it as the co_await result.

For example:

static future<bool> did_future_fail(future<> fut) {
auto f = co_await coroutine::as_future(std::move(fut));
if (f.failed()) {
mylog.warn("Future failed: {}", f.get_exception());
co_return true;
} else {
co_return false;
}
}
co_await:s a future, returning it as result.
Definition: as_future.hh:86

Note that by default, as_future checks for if the task quota is depleted, which means that it will yield if the future is ready and seastar::need_preempt() returns true. Use coroutine::as_future_without_preemption_check to disable preemption checking.

#include <seastar/coroutine/as_future.hh>

Inheritance diagram for seastar::coroutine::as_future< T >:

Public Member Functions

 as_future (seastar::future< T > &&f) noexcept
 

The documentation for this class was generated from the following file: