cortex 0.0.1
Loading...
Searching...
No Matches
cortex::BaseCoroutine Class Referenceabstract

An abstract base class for creating object-oriented coroutines. More...

#include <base_coroutine.hpp>

Inheritance diagram for cortex::BaseCoroutine:
[legend]

Public Member Functions

virtual ~BaseCoroutine ()=0
 Pure virtual destructor.
 
bool IsDone () const noexcept
 Checks if the coroutine has finished its execution.
 
void Resume ()
 Resumes the execution of the coroutine.
 

Protected Member Functions

 BaseCoroutine (std::size_t stack_size_bytes=262144, MemoryResourceSharedPtr resource=GetDefaultMemoryResource())
 Constructs a new BaseCoroutine.
 

Detailed Description

An abstract base class for creating object-oriented coroutines.

This class provides a way to define coroutines by inheriting from it and implementing the Continuation() method. It wraps the Coroutine class to provide a more object-oriented interface.

Constructor & Destructor Documentation

◆ ~BaseCoroutine()

virtual cortex::BaseCoroutine::~BaseCoroutine ( )
pure virtual

Pure virtual destructor.

Although it is pure virtual, it must have an implementation in the .cpp file.

◆ BaseCoroutine()

cortex::BaseCoroutine::BaseCoroutine ( std::size_t  stack_size_bytes = 262144,
MemoryResourceSharedPtr  resource = GetDefaultMemoryResource() 
)
explicitprotected

Constructs a new BaseCoroutine.

Parameters
stack_size_bytesThe size of the stack to allocate for the coroutine (default: 256KB).
resourceThe memory resource to use for stack and implementation allocation (default: GetDefaultMemoryResource()).

Member Function Documentation

◆ IsDone()

bool cortex::BaseCoroutine::IsDone ( ) const
inlinenoexcept

Checks if the coroutine has finished its execution.

Returns
true if execution is complete, false otherwise.

◆ Resume()

void cortex::BaseCoroutine::Resume ( )
inline

Resumes the execution of the coroutine.

If the coroutine was suspended, it continues from the suspension point. Execution will enter or resume in the Continuation() method.


The documentation for this class was generated from the following file: