cortex 0.0.1
Loading...
Searching...
No Matches
base_coroutine.hpp
Go to the documentation of this file.
1#pragma once
2
6
7#include <cstddef>
8
14namespace cortex {
15
25public:
31 virtual ~BaseCoroutine() = 0;
32
37 [[nodiscard]] bool IsDone() const noexcept {
38 return coroutine_.IsDone();
39 }
40
47 void Resume() {
48 coroutine_.Resume();
49 }
50
51protected:
59 explicit BaseCoroutine(std::size_t stack_size_bytes = 262144,
61
62private:
69 virtual void Continuation(CoroutineSuspendContext& self) = 0;
70
71private:
72 Coroutine coroutine_;
73};
74
75} // namespace cortex
An abstract base class for creating object-oriented coroutines.
Definition base_coroutine.hpp:24
BaseCoroutine(std::size_t stack_size_bytes=262144, MemoryResourceSharedPtr resource=GetDefaultMemoryResource())
Constructs a new BaseCoroutine.
void Resume()
Resumes the execution of the coroutine.
Definition base_coroutine.hpp:47
virtual ~BaseCoroutine()=0
Pure virtual destructor.
bool IsDone() const noexcept
Checks if the coroutine has finished its execution.
Definition base_coroutine.hpp:37
Provides a mechanism for a coroutine to suspend itself.
Definition coroutine_suspend_context.hpp:17
A stackful coroutine that provides a mechanism for cooperative multitasking.
Definition coroutine.hpp:28
void Resume()
Resumes the execution of the coroutine.
bool IsDone() const noexcept
Checks if the coroutine has finished its execution.
Main entry point for the cortex coroutine library.
Context for suspending coroutine execution.
Definition base_coroutine.hpp:14
MemoryResourceSharedPtr GetDefaultMemoryResource()
std::shared_ptr< MemoryResource > MemoryResourceSharedPtr
Definition memory_resource.hpp:30