87 std::size_t stack_size_bytes_ {0};
107 [[nodiscard]]
bool IsDone() const noexcept;
122 void operator()(detail::CoroutineImpl* impl)
const;
125 explicit Coroutine(std::unique_ptr<detail::CoroutineImpl, ImplDeleter> impl);
126 std::unique_ptr<detail::CoroutineImpl, ImplDeleter> impl_;
A stackful coroutine that provides a mechanism for cooperative multitasking.
Definition coroutine.hpp:28
Coroutine(const Coroutine &)=delete
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.
void Resume()
Resumes the execution of the coroutine.
bool IsDone() const noexcept
Checks if the coroutine has finished its execution.
static constexpr std::size_t kDefaultStackSizeBytes
Definition coroutine.hpp:30
std::size_t GetStackSize() const noexcept
Gets the allocated stack size of the coroutine.
Coroutine(Coroutine &&) noexcept
Definition of the coroutine execution body.
Definition base_coroutine.hpp:14
MemoryResourceSharedPtr GetDefaultMemoryResource()
std::shared_ptr< MemoryResource > MemoryResourceSharedPtr
Definition memory_resource.hpp:30
fu2::unique_function< void(CoroutineSuspendContext &)> CoroutineBody
The signature for a coroutine's entry point.
Definition coroutine_body.hpp:21
A builder class for creating Coroutine instances with custom configuration.
Definition coroutine.hpp:52
Builder()
Default constructor for Builder.
Builder SetMemoryResource(MemoryResourceSharedPtr resource) &&noexcept
Sets the memory resource for the coroutine to be built.
Builder SetStackSizeInBytes(std::size_t stack_size_bytes) &&noexcept
Sets the stack size for the coroutine to be built.
Coroutine Build(CoroutineBody body) &&
Builds and returns a new Coroutine instance.