Seastar
High performance C++ framework for concurrent servers
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
seastar::coroutine::switch_to Struct Referencefinal

Detailed Description

Switch the current task scheduling group.

switch_to(new_scheduling_group) can be used to change the scheduling_group of the currently running coroutine.

If the new scheduling group is different than the current scheduling_group, the coroutine is re-scheduled using the new scheduling group. Otherwise, the coroutine just continues to run with the current scheduling group.

switch_to returns the current scheduling group to make it easy to switch back to it if needed.

Example

... // do some preliminary work
auto prev_sg = co_await coroutine::switch_to(other_sg);
... // do some work using another scheduling group
co_await coroutine::switch_to(prev_sg);
... // do some more work
co_return;
}
A representation of a possibly not-yet-computed value.
Definition: future.hh:1197
Definition: switch_to.hh:55

#include <seastar/coroutine/switch_to.hh>

Inheritance diagram for seastar::coroutine::switch_to:
seastar::task

Public Member Functions

 switch_to (scheduling_group new_sg) noexcept
 
 switch_to (const switch_to &)=delete
 
 switch_to (switch_to &&)=delete
 
bool await_ready () const noexcept
 
template<typename T >
void await_suspend (std::coroutine_handle< T > hndl) noexcept
 
scheduling_group await_resume ()
 
virtual void run_and_dispose () noexcept override
 
virtual taskwaiting_task () noexcept override
 Returns the next task which is waiting for this task to complete execution, or nullptr. More...
 
scheduling_group group () const
 
shared_backtrace get_backtrace () const
 
void make_backtrace () noexcept
 

Public Attributes

scheduling_group _prev_sg
 
scheduling_group _switch_to_sg
 
task_task = nullptr
 

Protected Member Functions

scheduling_group set_scheduling_group (scheduling_group new_sg) noexcept
 

Protected Attributes

scheduling_group _sg
 

Member Function Documentation

◆ run_and_dispose()

virtual void seastar::coroutine::switch_to::run_and_dispose ( )
inlineoverridevirtualnoexcept

Implements seastar::task.

◆ waiting_task()

virtual task * seastar::coroutine::switch_to::waiting_task ( )
inlineoverridevirtualnoexcept

Returns the next task which is waiting for this task to complete execution, or nullptr.

Implements seastar::task.


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