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::maybe_yield Class Reference

Detailed Description

Preempt if the current task quota expired.

maybe_yield() can be used to break a long computation in a coroutine and allow the reactor to preempt its execution. This allows other tasks to gain access to the CPU. If the task quota did not expire, the coroutine continues execution.

It should be used in long loops that do not contain other co_await calls.

Example

seastar::future<int> long_loop(int n) {
float acc = 0;
for (int i = 0; i < n; ++i) {
acc += std::sin(float(i));
}
co_return acc;
}
A representation of a possibly not-yet-computed value.
Definition: future.hh:1197
future maybe_yield() noexcept
Definition: later.hh:57

#include <seastar/coroutine/maybe_yield.hh>

Public Member Functions

auto operator co_await ()
 

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