Seastar
High performance C++ framework for concurrent servers
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Classes | Public Member Functions | Protected Attributes | List of all members
seastar::concrete_execution_stage< ReturnType, Args > Class Template Referencefinal

Detailed Description

template<typename ReturnType, typename... Args>
requires std::is_nothrow_move_constructible_v<std::tuple<Args...>>
class seastar::concrete_execution_stage< ReturnType, Args >

Concrete execution stage class.

Note
The recommended way of creating execution stages is to use make_execution_stage().
Template Parameters
ReturnTypereturn type of the function object
Argsargument pack containing arguments to the function object, needs to have move constructor that doesn't throw

#include <seastar/core/execution_stage.hh>

Inheritance diagram for seastar::concrete_execution_stage< ReturnType, Args >:
seastar::execution_stage

Public Member Functions

 concrete_execution_stage (const sstring &name, scheduling_group sg, noncopyable_function< ReturnType(Args...)> f)
 
 concrete_execution_stage (const sstring &name, noncopyable_function< ReturnType(Args...)> f)
 
return_type operator() (typename internal::wrap_for_es< Args >::type... args)
 
const sstring & name () const noexcept
 Returns execution stage name.
 
const statsget_stats () const noexcept
 Returns execution stage usage statistics.
 
bool flush () noexcept
 
bool poll () const noexcept
 

Protected Attributes

bool _empty = true
 
bool _flush_scheduled = false
 
scheduling_group _sg
 
stats _stats
 
sstring _name
 
metrics::metric_group _metric_group
 

Member Function Documentation

◆ flush()

bool seastar::execution_stage::flush ( )
noexceptinherited

Flushes execution stage

Ensures that a task which would execute all queued operations is scheduled. Does not schedule a new task if there is one already pending or the queue is empty.

Returns
true if a new task has been scheduled

◆ operator()()

template<typename ReturnType , typename... Args>
return_type seastar::concrete_execution_stage< ReturnType, Args >::operator() ( typename internal::wrap_for_es< Args >::type...  args)
inline

Enqueues a call to the stage's function

Adds a function call to the queue. Objects passed by value are moved, rvalue references are decayed and the objects are moved, lvalue references need to be explicitly wrapped using seastar::ref().

Usage example:

void do_something(int&, int, std::vector<int>&&);
thread_local auto stage = seastar::make_execution_stage("execution-stage", do_something);
int global_value;
future<> func(std::vector<int> vec) {
//return stage(global_value, 42, std::move(vec)); // fail: use seastar::ref to pass references
return stage(seastar::ref(global_value), 42, std::move(vec)); // ok
}
A representation of a possibly not-yet-computed value.
Definition: future.hh:1219
auto make_execution_stage(const sstring &name, scheduling_group sg, Function &&fn)
Definition: execution_stage.hh:451
reference_wrapper< T > ref(T &object) noexcept
Wraps reference in a reference_wrapper.
Definition: reference_wrapper.hh:62
Parameters
argsarguments passed to the stage's function
Returns
future containing the result of the call to the stage's function

◆ poll()

bool seastar::execution_stage::poll ( ) const
inlinenoexceptinherited

Checks whether there are pending operations.

Returns
true if there is at least one queued operation

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