gem5 v24.0.0.0
Loading...
Searching...
No Matches
The Coroutine API.

Functions

template<typename T = Ret>
CallerTypegem5::Coroutine< Arg, Ret >::CallerType::operator() (typename std::enable_if_t< !std::is_same_v< T, void >, T > param)
 operator() is the way we can jump outside the coroutine and return a value to the caller.
 
template<typename T = Ret>
std::enable_if_t< std::is_same_v< T, void >, CallerType > & gem5::Coroutine< Arg, Ret >::CallerType::operator() ()
 operator() is the way we can jump outside the coroutine
 
template<typename T = Arg>
std::enable_if_t<!std::is_same_v< T, void >, T > gem5::Coroutine< Arg, Ret >::CallerType::get ()
 get() is the way we can extrapolate arguments from the coroutine caller.
 
 gem5::Coroutine< Arg, Ret >::Coroutine (std::function< void(CallerType &)> f, bool run_coroutine=true)
 Coroutine constructor.
 
virtual gem5::Coroutine< Arg, Ret >::~Coroutine ()
 
template<typename T = Arg>
Coroutinegem5::Coroutine< Arg, Ret >::operator() (typename std::enable_if_t<!std::is_same_v< T, void >, T > param)
 Coroutine interface.
 
template<typename T = Arg>
std::enable_if_t< std::is_same_v< T, void >, Coroutine > & gem5::Coroutine< Arg, Ret >::operator() ()
 operator() is the way we can jump inside the coroutine.
 
template<typename T = Ret>
std::enable_if_t<!std::is_same_v< T, void >, T > gem5::Coroutine< Arg, Ret >::get ()
 get() is the way we can extrapolate return values (yielded) from the coroutine.
 
 gem5::Coroutine< Arg, Ret >::operator bool () const
 Check if coroutine is still running.
 
 gem5::Coroutine< Arg, Ret >::Coroutine ()=delete
 
 gem5::Coroutine< Arg, Ret >::Coroutine (const Coroutine &rhs)=delete
 
Coroutinegem5::Coroutine< Arg, Ret >::operator= (const Coroutine &rhs)=delete
 

Detailed Description

These methods relate to the Coroutine interface.

Function Documentation

◆ Coroutine() [1/3]

template<typename Arg , typename Ret >
gem5::Coroutine< Arg, Ret >::Coroutine ( )
delete

◆ Coroutine() [2/3]

template<typename Arg , typename Ret >
gem5::Coroutine< Arg, Ret >::Coroutine ( const Coroutine< Arg, Ret > & rhs)
delete

◆ Coroutine() [3/3]

template<typename Arg , typename Ret >
gem5::Coroutine< Arg, Ret >::Coroutine ( std::function< void(CallerType &)> f,
bool run_coroutine = true )
inline

Coroutine constructor.

The only way to construct a coroutine is to pass it the routine it needs to run. The first argument of the function should be a reference to the Coroutine<Arg,Ret>::caller_type which the routine will use as a way for yielding to the caller. The optional second boolean argument controls if the Coroutine should be run on creation, which mimics Boost's Coroutine semantics by default. This can be disabled as an optimization to avoid unnecessary context switches on Coroutine creation.

Parameters
ftask run by the coroutine
run_coroutineset to false to disable running the coroutine immediately after it is created

Definition at line 185 of file coroutine.hh.

References gem5::Coroutine< Arg, Ret >::call().

◆ get() [1/2]

template<typename Arg , typename Ret >
template<typename T = Arg>
std::enable_if_t<!std::is_same_v< T, void >, T > gem5::Coroutine< Arg, Ret >::CallerType::get ( )
inline

get() is the way we can extrapolate arguments from the coroutine caller.

The coroutine blocks, waiting for the value, unless it is already available; otherwise caller execution is resumed, and coroutine won't execute until a value is pushed from the caller.

Returns
arg coroutine argument

Definition at line 141 of file coroutine.hh.

References gem5::Coroutine< Arg, Ret >::argsChannel, gem5::Coroutine< Arg, Ret >::CallerType::callerFiber, gem5::Coroutine< Arg, Ret >::CallerType::coro, and gem5::Fiber::run().

Referenced by gem5::SMMUTranslationProcess::completeTransaction(), gem5::ItsProcess::doRead(), gem5::SMMUProcess::doRead(), gem5::ItsProcess::doWrite(), gem5::SMMUProcess::doWrite(), and gem5::ItsTranslation::main().

◆ get() [2/2]

template<typename Arg , typename Ret >
template<typename T = Ret>
std::enable_if_t<!std::is_same_v< T, void >, T > gem5::Coroutine< Arg, Ret >::get ( )
inline

get() is the way we can extrapolate return values (yielded) from the coroutine.

The caller blocks, waiting for the value, unless it is already available; otherwise coroutine execution is resumed, and caller won't execute until a value is yielded back from the coroutine.

Returns
ret yielded value

Definition at line 249 of file coroutine.hh.

References gem5::Coroutine< Arg, Ret >::call(), gem5::Coroutine< Arg, Ret >::caller, and gem5::Coroutine< Arg, Ret >::CallerType::retChannel.

Referenced by TEST(), TEST(), TEST(), and TEST().

◆ operator bool()

template<typename Arg , typename Ret >
gem5::Coroutine< Arg, Ret >::operator bool ( ) const
inline

Check if coroutine is still running.

Definition at line 266 of file coroutine.hh.

References gem5::Fiber::finished().

◆ operator()() [1/4]

template<typename Arg , typename Ret >
template<typename T = Ret>
std::enable_if_t< std::is_same_v< T, void >, CallerType > & gem5::Coroutine< Arg, Ret >::CallerType::operator() ( )
inline

operator() is the way we can jump outside the coroutine

This method is generated only if the coroutine doesn't return a value (Ret = void)

Definition at line 121 of file coroutine.hh.

References gem5::Coroutine< Arg, Ret >::CallerType::callerFiber, and gem5::Fiber::run().

◆ operator()() [2/4]

template<typename Arg , typename Ret >
template<typename T = Ret>
CallerType & gem5::Coroutine< Arg, Ret >::CallerType::operator() ( typename std::enable_if_t< !std::is_same_v< T, void >, T > param)
inline

operator() is the way we can jump outside the coroutine and return a value to the caller.

This method is generated only if the coroutine returns a value (Ret != void)

Definition at line 102 of file coroutine.hh.

References gem5::Coroutine< Arg, Ret >::CallerType::callerFiber, gem5::Coroutine< Arg, Ret >::CallerType::retChannel, and gem5::Fiber::run().

◆ operator()() [3/4]

template<typename Arg , typename Ret >
template<typename T = Arg>
std::enable_if_t< std::is_same_v< T, void >, Coroutine > & gem5::Coroutine< Arg, Ret >::operator() ( )
inline

operator() is the way we can jump inside the coroutine.

This method is generated only if the coroutine takes no arguments. (Arg = void)

Definition at line 229 of file coroutine.hh.

References gem5::Coroutine< Arg, Ret >::call().

◆ operator()() [4/4]

template<typename Arg , typename Ret >
template<typename T = Arg>
Coroutine & gem5::Coroutine< Arg, Ret >::operator() ( typename std::enable_if_t<!std::is_same_v< T, void >, T > param)
inline

Coroutine interface.

operator() is the way we can jump inside the coroutine and passing arguments.

This method is generated only if the coroutine takes arguments (Arg != void)

Definition at line 212 of file coroutine.hh.

References gem5::Coroutine< Arg, Ret >::argsChannel, and gem5::Coroutine< Arg, Ret >::call().

◆ operator=()

template<typename Arg , typename Ret >
Coroutine & gem5::Coroutine< Arg, Ret >::operator= ( const Coroutine< Arg, Ret > & rhs)
delete

◆ ~Coroutine()

template<typename Arg , typename Ret >
virtual gem5::Coroutine< Arg, Ret >::~Coroutine ( )
inlinevirtual

Definition at line 196 of file coroutine.hh.


Generated on Tue Jun 18 2024 16:24:09 for gem5 by doxygen 1.11.0