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