|
tin
1.5.9
|
Channels are fixed-capacity local storage for typed values. They are the basic tin primitive for moving samples, commands, decoded records, or HSM events between parts of one process or firmware image.
A channel owns storage. Senders, receivers, latest readers, actors, and adapters may hold non-owning views into that storage.
tin::channel<T, Capacity> for the default reject-newest policy.tin::channel<T, Capacity, OverflowPolicy> when the overflow policy is part of the type.tin::overflow::reject_newest, tin::overflow::drop_oldest, and tin::overflow::overwrite_latest.sender(), receiver(), and latest_reader() for non-owning views.try_send, try_send_from_isr, and try_receive for bounded movement.receive() for coroutine tasks that should suspend until a value is available.The default overflow policy is reject_newest: a full channel rejects the new value and preserves already queued values.
Use drop_oldest when fresh data is more important than old data:
Use overwrite_latest for latest-sample channels:
overwrite_latest is for current-value streams. Use FIFO policies when every accepted value must be processed.
Handles narrow authority without transferring ownership.
The channel still owns the queue. The sender cannot receive, and the receiver cannot send.
Use channels when a component needs bounded local storage. Use actors when the component also needs a step/drain execution surface. A sensor actor, for example, may own a tin::channel<Sample, 4> and expose try_receive through an output port.
Related pages: