|
cortex 0.0.1
|
A stackful coroutine that provides a mechanism for cooperative multitasking. More...
#include <coroutine.hpp>
Classes | |
| struct | Builder |
| A builder class for creating Coroutine instances with custom configuration. More... | |
Public Member Functions | |
| Coroutine (const Coroutine &)=delete | |
| Coroutine (Coroutine &&) noexcept | |
| Coroutine & | operator= (const Coroutine &)=delete |
| Coroutine & | operator= (Coroutine &&) noexcept |
| ~Coroutine () | |
| std::size_t | GetStackSize () const noexcept |
| Gets the allocated stack size of the coroutine. | |
| bool | IsDone () const noexcept |
| Checks if the coroutine has finished its execution. | |
| void | Resume () |
| Resumes the execution of the coroutine. | |
Static Public Member Functions | |
| static Coroutine | Make (CoroutineBody body, std::size_t stack_size_bytes=kDefaultStackSizeBytes, MemoryResourceSharedPtr resource=GetDefaultMemoryResource()) |
| Creates a new coroutine with the specified body and stack size. | |
Static Public Attributes | |
| static constexpr std::size_t | kDefaultStackSizeBytes = 262144 |
A stackful coroutine that provides a mechanism for cooperative multitasking.
The Coroutine class manages a separate execution stack and allows suspending and resuming execution. It follows the PIMPL pattern to provide a unified API across different platforms (Native and Emscripten).
|
delete |
|
noexcept |
| cortex::Coroutine::~Coroutine | ( | ) |
|
noexcept |
Gets the allocated stack size of the coroutine.
|
noexcept |
Checks if the coroutine has finished its execution.
|
static |
Creates a new coroutine with the specified body and stack size.
| body | The function or callable to execute within the coroutine. |
| stack_size_bytes | The size of the stack to allocate for the coroutine (default: 256KB). |
| resource | The memory resource to use for stack and implementation allocation (default: GetDefaultMemoryResource()). |
| std::invalid_argument | if the body is empty or stack_size_bytes is 0 or resource is null. |
| void cortex::Coroutine::Resume | ( | ) |
Resumes the execution of the coroutine.
If the coroutine was suspended, it continues from the suspension point. If an exception was caught inside the coroutine, it will be rethrown here.
| ResumeOnDoneCoroutineError | if attempting to resume a finished coroutine. |
|
staticconstexpr |