mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
thread_local_continuation_scheduler.hpp
1#ifndef MRS_LIB_CORO_INTERNAL_THREAD_LOCAL_CONTINUATION_SCHEDULER_HPP_
2#define MRS_LIB_CORO_INTERNAL_THREAD_LOCAL_CONTINUATION_SCHEDULER_HPP_
3
4
5#include <coroutine>
6
7namespace mrs_lib::internal
8{
9
10 // This is a workaround to GCC generated code overflowing stack when using symmetric transfer
11
12 void resume_coroutine(std::coroutine_handle<> handle);
13 void schedule_coroutine_continuation(std::coroutine_handle<> handle);
14
16 {
23
24 // Always suspend the task
25 bool await_ready() noexcept
26 {
27 return false;
28 }
29
30 // Move the task to the thread local scheduler
31 void await_suspend(std::coroutine_handle<> task_handle) noexcept
32 {
33 resume_coroutine(task_handle);
34 }
35
36 // The task is moved, return nothing
37 void await_resume() noexcept
38 {
39 }
40 };
41
42} // namespace mrs_lib::internal
43
44
45#endif // MRS_LIB_CORO_INTERNAL_THREAD_LOCAL_CONTINUATION_SCHEDULER_HPP_
Definition thread_local_continuation_scheduler.hpp:16