tin  1.5.9
tsm::runtime Namespace Reference

Namespaces

 detail
 
 overflow
 
 scheduler
 
 storage
 
 topology
 
 transport
 

Classes

struct  actor_resources
 
struct  input_port
 
struct  output_port
 
struct  actor_link
 
struct  actor_group
 
struct  actor_group_resources
 Aggregate resource summaries for several actor types. More...
 
class  app
 
struct  inline_executor
 
class  runtime_group
 
class  task_spawner
 
class  basic_cooperative_executor
 
class  cooperative_executor
 
class  priority_cooperative_executor
 
class  tick_executor
 
struct  resource_snapshot
 
struct  resource_budget
 
struct  task_group_resources
 
struct  runtime_resources
 
struct  resource_contract
 
struct  profile_resource_contract
 
class  sender
 
class  receiver
 
class  latest_reader
 
class  channel
 

Typedefs

template<std::size_t Capacity>
using timer_queue = detail::timer_queue< Capacity >
 
template<typename Runtime >
using task_resources = detail::task_resources< Runtime >
 
template<typename Executor >
using spawner = task_spawner< Executor >
 
template<typename Runtime , std::size_t Capacity = 16U>
using delayed_event_timer = tick_executor< Runtime, Capacity >
 
template<typename Topology , typename Storage , typename Scheduler = void, typename Overflow = ::tsm::overflow::reject_newest, typename Transport = void>
using policy = ::tsm::runtime_policy< Topology, Storage, Scheduler, Overflow, Transport >
 
template<typename Definition , typename Policy , template< typename > class MachinePolicy = detail::default_machine_policy>
using Runtime = detail::runtime_impl< Definition, Policy, MachinePolicy >
 
template<typename Definition , typename Policy , template< typename > class MachinePolicy = detail::default_machine_policy>
using runtime_for = Runtime< Definition, Policy, MachinePolicy >
 
template<typename Definition , template< typename > class MachinePolicy = detail::default_machine_policy>
using direct_runtime = Runtime< Definition, ::tsm::runtime_policy<::tsm::dispatch_model::direct, ::tsm::queue_policy<::tsm::static_storage< 2 > >>, MachinePolicy >
 
template<typename Definition , std::size_t Capacity, typename Overflow = overflow::reject_newest, template< typename > class MachinePolicy = detail::default_machine_policy>
using queued_runtime = Runtime< Definition, ::tsm::runtime_policy< ::tsm::dispatch_model::queued, ::tsm::queue_policy<::tsm::target_storage< Capacity >, Overflow > >, MachinePolicy >
 
template<typename Definition , std::size_t Capacity, typename Overflow = overflow::reject_newest, template< typename > class MachinePolicy = detail::default_machine_policy>
using per_region_runtime = Runtime< Definition, ::tsm::runtime_policy< ::tsm::dispatch_model::per_region_queued, ::tsm::queue_policy<::tsm::target_storage< Capacity >, Overflow > >, MachinePolicy >
 

Functions

template<typename Event , typename Sink >
constexpr input_port< Event, Sink > make_input_port (Sink &sink)
 
template<typename Event , typename Source >
constexpr output_port< Event, Source > make_output_port (Source &source)
 
template<typename Source , typename Sink >
 actor_link (Source &, Sink &) -> actor_link< Source, Sink >
 
template<typename... Links>
bool link_all (Links &... links)
 
template<typename... Actors>
 actor_group (Actors &...) -> actor_group< Actors... >
 
template<typename... Runtimes>
 runtime_group (Runtimes &...) -> runtime_group< Runtimes... >
 
template<typename... Tasks>
 cooperative_executor (Tasks &...) -> cooperative_executor< Tasks... >
 
template<typename... Tasks>
 priority_cooperative_executor (Tasks &...) -> priority_cooperative_executor< Tasks... >
 
template<typename TickSource , typename Executor , typename DelayedEvents >
tsm::tick_rep drive_elapsed_ticks (TickSource &tick_source, Executor &executor, DelayedEvents &delayed_events)
 
template<typename Runtime >
 tick_executor (Runtime &) -> tick_executor< Runtime >
 
template<typename Stream >
void write_resource_manifest (Stream &output, char const *name, resource_snapshot const &snapshot)
 
consteval bool fits (resource_snapshot const &snapshot, resource_budget const &budget)
 

Variables

template<typename Actor >
concept actor_like
 
template<typename Actor , typename Event >
concept actor_sink
 
template<typename Actor , typename Event >
concept actor_source
 
template<typename Source , typename Sink >
concept compatible_link
 
template<typename Queue , typename Event >
concept queue_storage
 
template<typename Storage , typename Event >
concept queue_storage_policy
 
template<typename Policy >
concept runtime_queue_policy
 
template<typename Sink , typename Event >
concept event_sink
 
template<typename Source , typename Event >
concept event_source
 
template<typename Runtime >
concept caller_driven_runtime
 
template<typename Executor >
concept executor_backend
 
template<typename Executor >
concept wake_executor_backend
 
template<typename Policy >
concept runtime_policy
 

Typedef Documentation

◆ delayed_event_timer

template<typename Runtime , std::size_t Capacity = 16U>
using tsm::runtime::delayed_event_timer = typedef tick_executor<Runtime, Capacity>

◆ direct_runtime

template<typename Definition , template< typename > class MachinePolicy = detail::default_machine_policy>
using tsm::runtime::direct_runtime = typedef Runtime<Definition, ::tsm::runtime_policy<::tsm::dispatch_model::direct, ::tsm::queue_policy<::tsm::static_storage<2> >>, MachinePolicy>

◆ per_region_runtime

template<typename Definition , std::size_t Capacity, typename Overflow = overflow::reject_newest, template< typename > class MachinePolicy = detail::default_machine_policy>
using tsm::runtime::per_region_runtime = typedef Runtime<Definition, ::tsm::runtime_policy< ::tsm::dispatch_model::per_region_queued, ::tsm::queue_policy<::tsm::target_storage<Capacity>, Overflow> >, MachinePolicy>

◆ policy

template<typename Topology , typename Storage , typename Scheduler = void, typename Overflow = ::tsm::overflow::reject_newest, typename Transport = void>
using tsm::runtime::policy = typedef ::tsm::runtime_policy<Topology, Storage, Scheduler, Overflow, Transport>

◆ queued_runtime

template<typename Definition , std::size_t Capacity, typename Overflow = overflow::reject_newest, template< typename > class MachinePolicy = detail::default_machine_policy>
using tsm::runtime::queued_runtime = typedef Runtime<Definition, ::tsm::runtime_policy< ::tsm::dispatch_model::queued, ::tsm::queue_policy<::tsm::target_storage<Capacity>, Overflow> >, MachinePolicy>

◆ Runtime

template<typename Definition , typename Policy , template< typename > class MachinePolicy = detail::default_machine_policy>
using tsm::runtime::Runtime = typedef detail::runtime_impl<Definition, Policy, MachinePolicy>

Runtime alias selected by definition and policy.

The alias chooses a concrete implementation from the topology tag in the policy. Public code names Runtime<Definition, Policy> while implementation details remain in runtime::detail.

◆ runtime_for

template<typename Definition , typename Policy , template< typename > class MachinePolicy = detail::default_machine_policy>
using tsm::runtime::runtime_for = typedef Runtime<Definition, Policy, MachinePolicy>

◆ spawner

template<typename Executor >
using tsm::runtime::spawner = typedef task_spawner<Executor>

◆ task_resources

template<typename Runtime >
using tsm::runtime::task_resources = typedef detail::task_resources<Runtime>

◆ timer_queue

template<std::size_t Capacity>
using tsm::runtime::timer_queue = typedef detail::timer_queue<Capacity>

Fixed-capacity integer-tick timer queue used by coroutine schedulers.

The scheduler owns this queue internally, but the type is public so tests, resource checks, and target adapters can exercise the same bounded timer admission rule without depending on implementation namespace names. The queue stores only explicit tick deadlines and sequence numbers; it has no chrono or OS dependency. Equal deadlines wake deterministically by sequence.

Function Documentation

◆ actor_group()

template<typename... Actors>
tsm::runtime::actor_group ( Actors &  ...) -> actor_group< Actors... >

◆ actor_link()

template<typename Source , typename Sink >
tsm::runtime::actor_link ( Source &  ,
Sink &   
) -> actor_link< Source, Sink >

◆ cooperative_executor()

template<typename... Tasks>
tsm::runtime::cooperative_executor ( Tasks &  ...) -> cooperative_executor< Tasks... >

◆ drive_elapsed_ticks()

template<typename TickSource , typename Executor , typename DelayedEvents >
tsm::tick_rep tsm::runtime::drive_elapsed_ticks ( TickSource &  tick_source,
Executor &  executor,
DelayedEvents &  delayed_events 
)

Advance runtime work from a single elapsed-tick source.

The tick source owns the platform-time boundary: SysTick, an RTOS tick counter, or a host clock adapter converts elapsed time into integer ticks. This helper then applies those same ticks to coroutine/task sleeps and to delayed HSM events before draining ready runtime work. Using one elapsed value keeps task timing and delayed event timing coherent on embedded targets.

◆ fits()

consteval bool tsm::runtime::fits ( resource_snapshot const &  snapshot,
resource_budget const &  budget 
)

◆ link_all()

template<typename... Links>
bool tsm::runtime::link_all ( Links &...  links)

Step several actor links in declaration order.

Returns true if at least one link moved a value or completed a pending retry. Each link receives at most one step.

◆ make_input_port()

template<typename Event , typename Sink >
constexpr input_port<Event, Sink> tsm::runtime::make_input_port ( Sink &  sink)
constexpr

Create an input port for one event type.

The returned port references sink; ownership remains with the caller.

◆ make_output_port()

template<typename Event , typename Source >
constexpr output_port<Event, Source> tsm::runtime::make_output_port ( Source &  source)
constexpr

Create an output port for one event type.

The returned port references source; ownership remains with the caller.

◆ priority_cooperative_executor()

template<typename... Tasks>
tsm::runtime::priority_cooperative_executor ( Tasks &  ...) -> priority_cooperative_executor< Tasks... >

◆ runtime_group()

template<typename... Runtimes>
tsm::runtime::runtime_group ( Runtimes &  ...) -> runtime_group< Runtimes... >

◆ tick_executor()

template<typename Runtime >
tsm::runtime::tick_executor ( Runtime ) -> tick_executor< Runtime >

◆ write_resource_manifest()

template<typename Stream >
void tsm::runtime::write_resource_manifest ( Stream &  output,
char const *  name,
resource_snapshot const &  snapshot 
)

Write a stable JSON resource manifest for one runtime snapshot.

The stream is supplied by the caller so the same function can write to std::ostream, a test double, or another host-side sink. The input snapshot is normally produced by the runtime resource accounting API.

Variable Documentation

◆ actor_like

template<typename Actor >
concept tsm::runtime::actor_like
Initial value:
= requires(Actor actor) {
{ actor.step() } -> std::convertible_to<bool>;
{ actor.drain() } -> std::convertible_to<std::size_t>;
{ actor.empty() } -> std::convertible_to<bool>;
{ actor.pending_events() } -> std::convertible_to<std::size_t>;
}
requires(!has_transition_type_c< T > &&has_transition_member_c< T >) struct transitions_of< T >
Definition: transition.h:479

Actor stepping contract.

An actor is any local component that can make bounded cooperative progress when the caller gives it a turn. The contract is intentionally structural so HSM runtimes, adapters, test sources, and application components can satisfy it without inheriting from a framework base class.

◆ actor_sink

template<typename Actor , typename Event >
concept tsm::runtime::actor_sink
Initial value:
= requires(Actor actor, Event event) {
{ actor.send_event(event) } -> std::convertible_to<bool>;
}

Actor ingress contract for one event type.

A sink accepts a typed event and reports whether admission succeeded. A false result normally means bounded storage was full or the component deliberately rejected the event.

◆ actor_source

template<typename Actor , typename Event >
concept tsm::runtime::actor_source
Initial value:
= requires(Actor actor, Event& event) {
{ actor.try_receive(event) } -> std::convertible_to<bool>;
}

Actor egress contract for one event type.

A source tries to move one typed value into caller-provided storage. A false result means no value is currently available.

◆ caller_driven_runtime

template<typename Runtime >
concept tsm::runtime::caller_driven_runtime
Initial value:
= requires(Runtime runtime)
{
{
runtime.step()
} -> std::convertible_to<bool>;
{
runtime.drain()
} -> std::convertible_to<std::size_t>;
{
runtime.empty()
} -> std::convertible_to<bool>;
{
runtime.pending_events()
} -> std::convertible_to<std::size_t>;
{
runtime.last_event_handled()
} -> std::convertible_to<bool>;
}
detail::runtime_impl< Definition, Policy, MachinePolicy > Runtime
Definition: runtime.h:531

◆ compatible_link

template<typename Source , typename Sink >
concept tsm::runtime::compatible_link
Initial value:
typename Source::event_type;
typename Sink::event_type;
requires std::same_as<typename Source::event_type,
typename Sink::event_type>;
} && requires(Source source, Sink sink, typename Source::event_type event) {
{ source.try_receive(event) } -> std::convertible_to<bool>;
{ sink.try_send(event) } -> std::convertible_to<bool>;
}

True when a source and sink port can be connected by actor_link.

Compatible links have the same event_type, the source can try to receive that type, and the sink can try to send that type.

◆ event_sink

template<typename Sink , typename Event >
concept tsm::runtime::event_sink
Initial value:
= requires(Sink sink, Event event)
{
{
sink.send_event(event)
} -> std::convertible_to<bool>;
}

◆ event_source

template<typename Source , typename Event >
concept tsm::runtime::event_source
Initial value:
= requires(Source source, Event& event)
{
{
source.try_receive(event)
} -> std::convertible_to<bool>;
}

◆ executor_backend

template<typename Executor >
concept tsm::runtime::executor_backend
Initial value:
= requires(Executor executor)
{
{
executor.step()
} -> std::convertible_to<bool>;
{
executor.run_ready()
} -> std::convertible_to<std::size_t>;
}

Executor backend contract.

An executor is intentionally smaller than a runtime. It decides when and how much ready work to run, but it does not own HSM semantics. Platform-specific wait primitives such as epoll, kevent, FreeRTOS notifications, Zephyr k_poll, or bare-metal interrupt flags should wake an executor that then calls a runtime through this shape.

◆ queue_storage

template<typename Queue , typename Event >
concept tsm::runtime::queue_storage
Initial value:
= requires(Queue queue, Event event, Event out)
{
typename Queue::value_type;
requires std::same_as<typename Queue::value_type, Event>;
{
queue.try_push(event)
} -> std::convertible_to<bool>;
{
queue.try_push(std::move(event))
} -> std::convertible_to<bool>;
{
queue.try_pop(out)
} -> std::convertible_to<bool>;
{
queue.empty()
} -> std::convertible_to<bool>;
{
queue.full()
} -> std::convertible_to<bool>;
{
queue.size()
} -> std::convertible_to<std::size_t>;
}

Queue storage contract used by runtime topologies.

Storage is value-based and bounded. A topology can enqueue typed erased events without depending on STL containers or dynamic allocation.

Invariants:

  • try_push never blocks and reports acceptance
  • try_pop never blocks and reports whether an event was produced
  • size, empty, and full describe the same bounded storage instance
  • the queue owns event values until they are popped

◆ queue_storage_policy

template<typename Storage , typename Event >
concept tsm::runtime::queue_storage_policy
Initial value:
{
typename Storage::template queue<Event>;
}
&&queue_storage<typename Storage::template queue<Event>, Event>

◆ runtime_policy

template<typename Policy >
concept tsm::runtime::runtime_policy
Initial value:
{
typename Policy::dispatch_model;
typename Policy::queue;
}
&&::tsm::dispatch_model_policy<typename Policy::dispatch_model>&&
runtime_queue_policy<typename Policy::queue>

◆ runtime_queue_policy

template<typename Policy >
concept tsm::runtime::runtime_queue_policy
Initial value:
{
typename Policy::storage;
typename Policy::overflow;
}
&&::tsm::overflow_policy<typename Policy::overflow>

◆ wake_executor_backend

template<typename Executor >
concept tsm::runtime::wake_executor_backend
Initial value:
= executor_backend<Executor> &&
requires(Executor executor)
{
executor.wake();
executor.wake_from_isr();
executor.wait_for_work();
}

Wake-aware executor backend contract.

Platform executors may block an OS task, host thread, or bare-metal idle loop when no cooperative work is ready. wake releases that wait surface, and wait_for_work performs one bounded target-specific wait. The runtime queue remains the event storage authority; the wake primitive is only a scheduling signal.