Go to the documentation of this file.
38 #ifndef __BASE_COROUTINE_HH__
39 #define __BASE_COROUTINE_HH__
62 template <
typename Arg,
typename Ret>
70 using ArgChannel =
typename std::conditional_t<
71 std::is_same_v<Arg, void>,
Empty, std::stack<Arg>>;
73 using RetChannel =
typename std::conditional_t<
74 std::is_same_v<Ret, void>,
Empty, std::stack<Ret>>;
100 template <
typename T = Ret>
103 !std::is_same_v<T, void>, T> param)
118 template <
typename T = Ret>
119 typename std::enable_if_t<std::is_same_v<T, void>,
139 template <
typename T = Arg>
140 typename std::enable_if_t<!std::is_same_v<T, void>, T>
144 while (args_channel.empty()) {
148 auto ret = args_channel.top();
210 template <
typename T = Arg>
212 operator()(
typename std::enable_if_t<!std::is_same_v<T, void>, T> param)
227 template <
typename T = Arg>
228 typename std::enable_if_t<std::is_same_v<T, void>,
Coroutine> &
247 template <
typename T = Ret>
248 typename std::enable_if_t<!std::is_same_v<T, void>, T>
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_t<!std::is_same_v< T, void >, T > get()
get() is the way we can extrapolate return values (yielded) from the coroutine.
void run()
Start executing the fiber represented by this object.
Coroutine(std::function< void(CallerType &)> f, bool run_coroutine=true)
Coroutine constructor.
static Fiber * currentFiber()
Get a pointer to the current running Fiber.
Coroutine & operator()(typename std::enable_if_t<!std::is_same_v< T, void >, T > param)
Coroutine interface.
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.
std::enable_if_t< std::is_same_v< T, void >, Coroutine > & operator()()
operator() is the way we can jump inside the coroutine.
Coroutine & operator=(const Coroutine &rhs)=delete
std::enable_if_t<!std::is_same_v< T, void >, T > get()
get() is the way we can extrapolate arguments from the coroutine caller.
This class represents a fiber, which is a light weight sort of thread which is cooperatively schedule...
std::enable_if_t< std::is_same_v< T, void >, CallerType > & operator()()
operator() is the way we can jump outside the coroutine
CallerType caller
Coroutine caller.
CallerType(Coroutine &_coro)
typename std::conditional_t< std::is_same_v< Arg, void >, Empty, std::stack< Arg > > ArgChannel
This template defines a Coroutine wrapper type with a Boost-like interface.
typename std::conditional_t< std::is_same_v< Ret, void >, Empty, std::stack< Ret > > RetChannel
bool finished() const
Returns whether the "main" function of this fiber has finished.
CallerType: A reference to an object of this class will be passed to the coroutine task.
std::function< void(CallerType &)> task
Coroutine task.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
void main() override
Overriding base (Fiber) main.
ArgChannel argsChannel
Arguments for the coroutine.
Generated on Sun Jul 30 2023 01:56:50 for gem5 by doxygen 1.8.17