Coroutine Class Reference

HiCR: HiCR::backend::boost::Coroutine Class Reference
HiCR
HiCR::backend::boost::Coroutine Class Reference

#include <coroutine.hpp>

Public Types

using coroutineFc_t = std::function< void(void *)>
 

Public Member Functions

__INLINE__ void resume ()
 
__INLINE__ void yield ()
 
__INLINE__ void start (const coroutineFc_t &fc, void *const arg)
 
__INLINE__ bool hasFinished ()
 

Detailed Description

Abstracts the basic functionality of a coroutine execution

Member Typedef Documentation

◆ coroutineFc_t

using HiCR::backend::boost::Coroutine::coroutineFc_t = std::function<void(void *)>

Defines the type accepted by the coroutine function

Member Function Documentation

◆ hasFinished()

__INLINE__ bool HiCR::backend::boost::Coroutine::hasFinished ( )
inline

A function to check whether the coroutine has finished execution completely

Returns
True, if the coroutine has finished; False, otherwise.

◆ resume()

__INLINE__ void HiCR::backend::boost::Coroutine::resume ( )
inline

Resumes the execution of the coroutine. The coroutine needs to have been started before this, otherwise undefined behavior is to be expected.

◆ start()

__INLINE__ void HiCR::backend::boost::Coroutine::start ( const coroutineFc_t fc,
void *const  arg 
)
inline

Creates the context of the coroutine.

This is separate from the class constructor to allow Just-in-time allocation of the stack. This enables the creation of many instances of this class, whereas only a few need to have an allocated stack at any given moment.

Parameters
[in]fcFunction to run by the coroutine
[in]argArgument (closure) to be passed to the function

◆ yield()

__INLINE__ void HiCR::backend::boost::Coroutine::yield ( )
inline

Yields the execution of the coroutine. The coroutine needs to be 'resumed' when running this function, otherwise undefined behavior is to be expected.


The documentation for this class was generated from the following file:
  • /home/runner/work/HiCR/HiCR/include/hicr/backends/boost/coroutine.hpp