Seastar
High performance C++ framework for concurrent servers
Public Member Functions | List of all members
seastar::coroutine::lambda< Func > Class Template Reference

Detailed Description

template<typename Func>
class seastar::coroutine::lambda< Func >

Make a lambda coroutine safe for use in an outer coroutine with functions that accept continuations.

A lambda coroutine is not a safe parameter to a function that expects a regular Seastar continuation.

To use, wrap the lambda coroutine in seastar::coroutine::lambda(). The lambda coroutine must complete (co_await) in the same statement.

Example::

// `future::then()` expects a continuation, so not safe for lambda
// coroutines without seastar::coroutine::lambda.
// use of `captures` here can break without seastar::coroutine::lambda.
}));
Definition: coroutine.hh:257
Result then(Func &&func) noexcept
Schedule a block of code to run when the future is ready.
Definition: future.hh:1410
future maybe_yield() noexcept
Definition: later.hh:57
future yield() noexcept
Returns a future which is not ready but is scheduled to resolve soon.
Template Parameters
Functype of function object (typically inferred)

#include <seastar/core/coroutine.hh>

Public Member Functions

 lambda (Func &&func)
 
template<typename... Args>
decltype(auto) operator() (Args &&... args) const
 Calls the lambda coroutine object. Normally invoked by Seastar.
 

Constructor & Destructor Documentation

◆ lambda()

template<typename Func >
seastar::coroutine::lambda< Func >::lambda ( Func &&  func)
inlineexplicit

Create a lambda coroutine wrapper from a function object, to be passed to a Seastar function that accepts a continuation.


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