tin  1.5.9
coroutine.h File Reference

Static coroutine tasks for tsm runtime executors. More...

#include <array>
#include <concepts>
#include <coroutine>
#include <cstddef>
#include <cstdint>
#include <tuple>
#include <type_traits>
#include <utility>
#include "tsm/ticks.h"
Include dependency graph for coroutine.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  tsm::task
 
class  tsm::static_coroutine_arena< Bytes >
 
class  tsm::task_context
 
struct  tsm::task::promise_type
 
struct  tsm::task::promise_type::final_awaitable
 
struct  tsm::yield_awaitable
 
struct  tsm::sleep_ticks_awaitable
 
class  tsm::periodic_ticks
 
struct  tsm::timeout_ticks_awaitable
 
struct  tsm::select_result
 Result of a select wait. More...
 
class  tsm::select_awaitable< Awaitables >
 
class  tsm::send_event_awaitable< Runtime, Event >
 
class  tsm::checked_send_event_awaitable< Runtime, Event >
 
class  tsm::until_active_awaitable< State, Machine >
 
struct  tsm::instances< Count >
 
struct  tsm::frame_bytes< Bytes >
 
struct  tsm::task_priority< Priority >
 
struct  tsm::dynamic_task_slots< Count, FrameBytes >
 
struct  tsm::task_group< Entries >
 
struct  tsm::task_def< Entry, Options >
 
struct  tsm::tasks< TaskDefinitions >
 

Namespaces

 tsm
 
 tsm::runtime
 
 tsm::runtime::detail
 

Typedefs

using tsm::every_ticks = periodic_ticks
 
template<typename Runtime >
using tsm::runtime::detail::coroutine_scheduler_for = coroutine_scheduler< Runtime, typename runtime_task_list_of< Runtime >::type >
 
template<typename Runtime >
using tsm::runtime::detail::priority_coroutine_scheduler_for = coroutine_scheduler< Runtime, typename runtime_task_list_of< Runtime >::type, true >
 
template<typename Runtime >
using tsm::runtime::detail::executor_task_binding = basic_executor_task_binding< Runtime, coroutine_scheduler_for >
 
template<typename Runtime >
using tsm::runtime::detail::priority_executor_task_binding = basic_executor_task_binding< Runtime, priority_coroutine_scheduler_for >
 
template<std::size_t Capacity>
using tsm::runtime::timer_queue = detail::timer_queue< Capacity >
 
template<typename Runtime >
using tsm::runtime::task_resources = detail::task_resources< Runtime >
 

Enumerations

enum class  tsm::task_wait_kind : unsigned char {
  tsm::ready , tsm::running , tsm::sleeping , tsm::predicate ,
  tsm::completed , tsm::failed
}
 
enum class  tsm::task_status : unsigned char {
  tsm::not_started , tsm::ready , tsm::running , tsm::waiting ,
  tsm::completed , tsm::failed
}
 
enum class  tsm::task_failure_reason : unsigned char {
  tsm::none , tsm::allocation_failed , tsm::frame_too_large , tsm::wait_queue_full ,
  tsm::timer_queue_full , tsm::cancelled , tsm::unhandled_exception
}
 
enum class  tsm::spawn_result : unsigned char {
  tsm::started , tsm::no_slot , tsm::frame_too_large , tsm::allocation_failed ,
  tsm::invalid_entry
}
 

Functions

task_context * tsm::runtime::detail::find_task_context () noexcept
 
template<typename First , typename... Rest>
task_context * tsm::runtime::detail::find_task_context (First &first, Rest &... rest) noexcept
 
yield_awaitable tsm::yield () noexcept
 
sleep_ticks_awaitable tsm::sleep_ticks (tsm::tick_rep ticks) noexcept
 
sleep_ticks_awaitable tsm::sleep_ticks (tick_count ticks) noexcept
 
sleep_ticks_awaitable tsm::after_ticks (tsm::tick_rep ticks) noexcept
 
sleep_ticks_awaitable tsm::after_ticks (tick_count ticks) noexcept
 
timeout_ticks_awaitable tsm::timeout_ticks (tsm::tick_rep ticks) noexcept
 
timeout_ticks_awaitable tsm::timeout_ticks (tick_count ticks) noexcept
 
template<typename Awaitable >
void tsm::runtime::detail::cancel_awaitable (Awaitable &awaitable, task_context &context) noexcept
 
template<typename... Awaitables>
auto tsm::select (Awaitables &&... awaitables)
 
template<typename Awaitable >
auto tsm::with_timeout (Awaitable &&awaitable, tsm::tick_rep ticks)
 
template<typename Awaitable >
auto tsm::with_timeout (Awaitable &&awaitable, tick_count ticks)
 
template<typename Runtime , typename Event >
auto tsm::send_event (Runtime &runtime, Event &&event)
 
template<typename Event , typename Runtime , typename... Args>
auto tsm::send (Runtime &runtime, Args &&... args)
 
template<typename Runtime , typename Event >
auto tsm::try_send_event (Runtime &runtime, Event &&event)
 
template<typename Event , typename Runtime , typename... Args>
auto tsm::try_send (Runtime &runtime, Args &&... args)
 
template<typename State , typename Machine >
auto tsm::until_active (Machine &machine) noexcept
 
consteval std::size_t tsm::runtime::detail::selected_instances ()
 
template<std::size_t Count, typename... Rest>
consteval std::size_t tsm::runtime::detail::selected_instances (tsm::instances< Count >, Rest...)
 
template<typename First , typename... Rest>
consteval std::size_t tsm::runtime::detail::selected_instances (First, Rest... rest)
 
consteval std::size_t tsm::runtime::detail::selected_frame_bytes ()
 
template<std::size_t Bytes, typename... Rest>
consteval std::size_t tsm::runtime::detail::selected_frame_bytes (tsm::frame_bytes< Bytes >, Rest...)
 
template<typename First , typename... Rest>
consteval std::size_t tsm::runtime::detail::selected_frame_bytes (First, Rest... rest)
 
consteval std::uint8_t tsm::runtime::detail::selected_priority ()
 
template<std::uint8_t Priority, typename... Rest>
consteval std::uint8_t tsm::runtime::detail::selected_priority (tsm::task_priority< Priority >, Rest...)
 
template<typename First , typename... Rest>
consteval std::uint8_t tsm::runtime::detail::selected_priority (First, Rest... rest)
 

Variables

template<typename Awaitable >
concept tsm::runtime::detail::basic_awaitable
 
template<typename Definition >
concept tsm::runtime::detail::declared_task_definition
 
template<typename Definition >
concept tsm::runtime::detail::dynamic_task_definition
 
template<auto Left, auto Right>
concept tsm::runtime::detail::same_task_entry
 

Detailed Description

Static coroutine tasks for tsm runtime executors.

Coroutine tasks describe application workflows that run beside an HSM runtime: "do this later", "wait for this condition", and "run this cooperative loop" without adding OS threads, heap allocation, or callback registration to state-machine definitions.

Use this when behavior needs a small cooperative workflow beside event dispatch: startup sequences, periodic service loops, deferred retries, or tests that wait on runtime state. Tasks can send typed events, yield, sleep for explicit tick counts, and wait for machine conditions; transitions still happen only when events are dispatched through the runtime.