ecor
Loading...
Searching...
No Matches
ecor::trnx_controller_source< T > Struct Template Reference

Source for scheduling transactions in a request-reply protocol (e.g. More...

#include <ecor.hpp>

Public Types

using sender_type = _trnx_controller_sender< T >
 

Public Member Functions

trnx_entry< T > * query_next_trnx ()
 Retrieve the next pending transaction entry for processing by the driver. More...
 
sender_type schedule (T val)
 Schedule a new transaction with the given user data. More...
 

Detailed Description

template<typename T>
struct ecor::trnx_controller_source< T >

Source for scheduling transactions in a request-reply protocol (e.g.

UART, SPI, I²C) where multiple transactions can be in flight simultaneously. The source will get user-defined type T as transaction payload and will return senders that complete when the transaction is completed by the driver.

The source maintains a linked list of pending transactions. Once a transaction is taken by the driver, it is removed from the list and handed off to the driver, which is responsible for managing it until completion.

On completion, the driver calls set_value/set_error/set_stopped on the transaction entry. The exact API is specified by the user-provided transaction data type T.

Architecture of the transaction abstraction:

  • trnx_controller_source<T> — schedules transactions, returns senders (this type)
  • trnx_entry<T> — type-erased linked-list node holding user data T
  • trnx_circular_buffer<T, N> — ISR-safe 4-cursor ring buffer for in-flight management

Usage:

  1. Call schedule(data) to get a sender representing the transaction.
  2. Connect the sender to a receiver and start().
  3. In the driver's tick loop, call query_next_trnx() to retrieve pending entries.
  4. Move entries into a circular buffer or process them directly.
  5. When the reply arrives, call set_value/set_error/set_stopped on the entry to complete the sender.

Stop semantics: stop tokens are checked only for pending transactions (still in the source's linked list). Once a transaction is moved outside, whenever it can be cancelled or not depends solely on the driver.

  • T: User-defined transaction data type providing get_completion_signatures.

Member Function Documentation

◆ query_next_trnx()

template<typename T >
trnx_entry< T > * ecor::trnx_controller_source< T >::query_next_trnx ( )
inline

Retrieve the next pending transaction entry for processing by the driver.

Returns nullptr if there are no pending transactions. Any transaction has been cancelled (stop token triggered) while it was pending, it will be removed from the list, set_stopped() will be called on it, and it will not be returned.

◆ schedule()

template<typename T >
sender_type ecor::trnx_controller_source< T >::schedule ( val)
inline

Schedule a new transaction with the given user data.

Returns a sender that completes when the transaction is completed by the driver.


The documentation for this struct was generated from the following file: