gem5  v21.1.0.2
Functions
The Coroutine API.

These methods relate to the Coroutine interface. More...

Functions

template<typename T = Ret>
CallerTypegem5::Coroutine< Arg, Ret >::CallerType::operator() (typename std::enable_if_t< !std::is_same< T, void >::value, T > param)
 operator() is the way we can jump outside the coroutine and return a value to the caller. More...
 
template<typename T = Ret>
std::enable_if_t< std::is_same< T, void >::value, CallerType > & gem5::Coroutine< Arg, Ret >::CallerType::operator() ()
 operator() is the way we can jump outside the coroutine More...
 
template<typename T = Arg>
std::enable_if_t<!std::is_same< T, void >::value, T > gem5::Coroutine< Arg, Ret >::CallerType::get ()
 get() is the way we can extrapolate arguments from the coroutine caller. More...
 
 gem5::Coroutine< Arg, Ret >::Coroutine (std::function< void(CallerType &)> f, bool run_coroutine=true)
 Coroutine constructor. More...
 
virtual gem5::Coroutine< Arg, Ret >::~Coroutine ()
 
template<typename T = Arg>
Coroutinegem5::Coroutine< Arg, Ret >::operator() (typename std::enable_if_t< !std::is_same< T, void >::value, T > param)
 Coroutine interface. More...
 
template<typename T = Arg>
std::enable_if_t< std::is_same< T, void >::value, Coroutine > & gem5::Coroutine< Arg, Ret >::operator() ()
 operator() is the way we can jump inside the coroutine. More...
 
template<typename T = Ret>
std::enable_if_t<!std::is_same< T, void >::value, T > gem5::Coroutine< Arg, Ret >::get ()
 get() is the way we can extrapolate return values (yielded) from the coroutine. More...
 
 gem5::Coroutine< Arg, Ret >::operator bool () const
 Check if coroutine is still running. More...
 
 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 186 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<T, void>::value, 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 142 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::SMMUProcess::doRead(), gem5::ItsProcess::doRead(), gem5::SMMUProcess::doWrite(), gem5::ItsProcess::doWrite(), and gem5::ItsTranslation::main().

◆ get() [2/2]

template<typename Arg , typename Ret >
template<typename T = Ret>
std::enable_if_t<!std::is_same<T, void>::value, 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 251 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().

◆ operator bool()

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

Check if coroutine is still running.

Definition at line 268 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<T, void>::value, 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 122 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 = Arg>
std::enable_if_t<std::is_same<T, void>::value, 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 231 of file coroutine.hh.

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

◆ operator()() [3/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< T, void >::value, 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 103 of file coroutine.hh.

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

◆ 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< T, void >::value, 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 213 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 197 of file coroutine.hh.


Generated on Tue Sep 21 2021 12:27:01 for gem5 by doxygen 1.8.17