gem5  v20.1.0.0
Functions
The Coroutine API.

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

Functions

template<typename T = Ret>
CallerTypem5::Coroutine< Arg, Ret >::CallerType::operator() (typename std::enable_if< !std::is_same< T, void >::value, T >::type 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< std::is_same< T, void >::value, CallerType >::typem5::Coroutine< Arg, Ret >::CallerType::operator() ()
 operator() is the way we can jump outside the coroutine More...
 
template<typename T = Arg>
std::enable_if<!std::is_same< T, void >::value, T >::type m5::Coroutine< Arg, Ret >::CallerType::get ()
 get() is the way we can extrapolate arguments from the coroutine caller. More...
 
 m5::Coroutine< Arg, Ret >::Coroutine (std::function< void(CallerType &)> f, bool run_coroutine=true)
 Coroutine constructor. More...
 
virtual m5::Coroutine< Arg, Ret >::~Coroutine ()
 
template<typename T = Arg>
Coroutinem5::Coroutine< Arg, Ret >::operator() (typename std::enable_if< !std::is_same< T, void >::value, T >::type param)
 Coroutine interface. More...
 
template<typename T = Arg>
std::enable_if< std::is_same< T, void >::value, Coroutine >::typem5::Coroutine< Arg, Ret >::operator() ()
 operator() is the way we can jump inside the coroutine. More...
 
template<typename T = Ret>
std::enable_if<!std::is_same< T, void >::value, T >::type m5::Coroutine< Arg, Ret >::get ()
 get() is the way we can extrapolate return values (yielded) from the coroutine. More...
 
 m5::Coroutine< Arg, Ret >::operator bool () const
 Check if coroutine is still running. More...
 
 m5::Coroutine< Arg, Ret >::Coroutine ()=delete
 
 m5::Coroutine< Arg, Ret >::Coroutine (const Coroutine &rhs)=delete
 
Coroutinem5::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 >
m5::Coroutine< Arg, Ret >::Coroutine ( )
delete

◆ Coroutine() [2/3]

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

◆ Coroutine() [3/3]

template<typename Arg , typename Ret >
m5::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 184 of file coroutine.hh.

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

◆ get() [1/2]

template<typename Arg , typename Ret >
template<typename T = Arg>
std::enable_if<!std::is_same<T, void>::value, T>::type m5::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 140 of file coroutine.hh.

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

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

◆ get() [2/2]

template<typename Arg , typename Ret >
template<typename T = Ret>
std::enable_if<!std::is_same<T, void>::value, T>::type m5::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 m5::Coroutine< Arg, Ret >::call(), m5::Coroutine< Arg, Ret >::caller, and m5::Coroutine< Arg, Ret >::CallerType::retChannel.

Referenced by TEST().

◆ operator bool()

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

Check if coroutine is still running.

Definition at line 266 of file coroutine.hh.

References Fiber::finished().

◆ operator()() [1/4]

template<typename Arg , typename Ret >
template<typename T = Ret>
std::enable_if<std::is_same<T, void>::value, CallerType>::type& m5::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 120 of file coroutine.hh.

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

◆ operator()() [2/4]

template<typename Arg , typename Ret >
template<typename T = Arg>
std::enable_if<std::is_same<T, void>::value, Coroutine>::type& m5::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 m5::Coroutine< Arg, Ret >::call().

◆ operator()() [3/4]

template<typename Arg , typename Ret >
template<typename T = Ret>
CallerType& m5::Coroutine< Arg, Ret >::CallerType::operator() ( typename std::enable_if< !std::is_same< T, void >::value, T >::type  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 101 of file coroutine.hh.

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

◆ operator()() [4/4]

template<typename Arg , typename Ret >
template<typename T = Arg>
Coroutine& m5::Coroutine< Arg, Ret >::operator() ( typename std::enable_if< !std::is_same< T, void >::value, T >::type  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 211 of file coroutine.hh.

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

◆ operator=()

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

◆ ~Coroutine()

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

Definition at line 195 of file coroutine.hh.


Generated on Wed Sep 30 2020 14:02:20 for gem5 by doxygen 1.8.17