Go to the documentation of this file.
38 #ifndef __BASE_COROUTINE_HH__
39 #define __BASE_COROUTINE_HH__
61 template <
typename Arg,
typename Ret>
70 std::is_same<Arg, void>::value,
Empty, std::stack<Arg>>
::type;
73 std::is_same<Ret, void>::value,
Empty, std::stack<Ret>>
::type;
99 template <
typename T = Ret>
102 !std::is_same<T, void>::value, T>::
type param)
117 template <
typename T = Ret>
118 typename std::enable_if<std::is_same<T, void>::value,
138 template <
typename T = Arg>
139 typename std::enable_if<!std::is_same<T, void>::value, T>
::type
143 while (args_channel.empty()) {
147 auto ret = args_channel.top();
209 template <
typename T = Arg>
212 !std::is_same<T, void>::value, T>::
type param)
227 template <
typename T = Arg>
228 typename std::enable_if<std::is_same<T, void>::value,
Coroutine>
::type&
247 template <
typename T = Ret>
248 typename std::enable_if<!std::is_same<T, void>::value, T>
::type
252 while (ret_channel.empty()) {
256 auto ret = ret_channel.top();
266 operator bool()
const {
return !this->
finished(); }
297 #endif // __BASE_COROUTINE_HH__
std::enable_if<!std::is_same< T, void >::value, T >::type get()
get() is the way we can extrapolate arguments from the coroutine caller.
std::function< void(CallerType &)> task
Coroutine task.
ArgChannel argsChannel
Arguments for the coroutine.
CallerType: A reference to an object of this class will be passed to the coroutine task.
bool finished() const
Returns whether the "main" function of this fiber has finished.
typename std::conditional< std::is_same< Arg, void >::value, Empty, std::stack< Arg > >::type ArgChannel
Coroutine & operator()(typename std::enable_if< !std::is_same< T, void >::value, T >::type param)
Coroutine interface.
std::enable_if< std::is_same< T, void >::value, Coroutine >::type & operator()()
operator() is the way we can jump inside the coroutine.
std::enable_if<!std::is_same< T, void >::value, T >::type get()
get() is the way we can extrapolate return values (yielded) from the coroutine.
This class represents a fiber, which is a light weight sort of thread which is cooperatively schedule...
static Fiber * currentFiber()
Get a pointer to the current running Fiber.
Coroutine & operator=(const Coroutine &rhs)=delete
void run()
Start executing the fiber represented by this object.
This template defines a Coroutine wrapper type with a Boost-like interface.
typename std::conditional< std::is_same< Ret, void >::value, Empty, std::stack< Ret > >::type RetChannel
CallerType(Coroutine &_coro)
void main() override
Overriding base (Fiber) main.
std::enable_if< std::is_same< T, void >::value, CallerType >::type & operator()()
operator() is the way we can jump outside the coroutine
CallerType caller
Coroutine caller.
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.
Coroutine(std::function< void(CallerType &)> f, bool run_coroutine=true)
Coroutine constructor.
Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17