Skip to main content

chronon::sender::ConnectionBase

More...

#include <Connection.hpp>

Inherited by chronon::sender::Connection< T >

Public Functions

Name
virtual~ConnectionBase() =default
virtual Unit *source() const =0
virtual voidsetThreadQueueId(size_t queue_id) =0
virtual voidsetConnId(uint32_t conn_id) =0
virtual size_tregisterProducerThread(size_t thread_id) =0
virtual class IArbitratablePort *registerOnDestMPSC() =0
virtual voidoptimizeForSameThread() =0
virtual voidoptimizeForSPSC() =0
virtual voidoptimizeForMPSC() =0
virtual std::optional< uint64_t >minStagedArrivalCycle() const
Earliest arrival currently staged on this MPSC connection, if any.
boolisTight() const
True if this is a zero-delay (tight) connection.
virtual boolhasThreadQueueId() const =0
True if this connection uses thread-specific queue (MPSC mode).
virtual boolensureEpochFreeHeadroom(uint32_t max_lookahead_cycles) =0
virtual Unit *destination() const =0
virtual void *destPortPtr() const =0
virtual uint32_tdelay() const =0
virtual size_tcrossThreadHeadroom() const
virtual uint32_tconnId() const =0
virtual voidconfigureRegisteredEdge(std::optional< size_t > capacity, std::optional< size_t > rate) =0
virtual voidcancelInFlight() =0
virtual size_tarbitrateAdmitErased(size_t budget) =0
virtual size_tarbitrateAdmitBoundedErased(size_t budget, uint64_t max_send_cycle) =0

Detailed Description

class chronon::sender::ConnectionBase;

ConnectionBase - Type-erased base class for connections.

Enables storing heterogeneous connections in containers.

Public Functions Documentation

function ~ConnectionBase

virtual ~ConnectionBase() =default

function source

virtual Unit * source() const =0

Reimplemented by: chronon::Connection::source, chronon::sender::Connection::source

function setThreadQueueId

virtual void setThreadQueueId(
size_t queue_id
) =0

Parameters:

  • queue_id The queue ID for this connection

Reimplemented by: chronon::Connection::setThreadQueueId, chronon::sender::Connection::setThreadQueueId

Set the thread queue ID for multi-producer mode.

Called during initialization when the destination InPort is in multi-producer mode.

function setConnId

virtual void setConnId(
uint32_t conn_id
) =0

Reimplemented by: chronon::Connection::setConnId, chronon::sender::Connection::setConnId

Stable connection identifier assigned at simulation build time.

Equal to this connection's index in TickSimulation::connections_. Used by MultiProducerQueueAdapter as a cross-num_workers-stable tiebreaker in the k-way merge, replacing the partition-dependent queue_id. The value is deterministic given a fixed topology, regardless of thread count / cluster assignment.

function registerProducerThread

virtual size_t registerProducerThread(
size_t thread_id
) =0

Parameters:

Return: Queue ID for this producer key, or SIZE_MAX on failure

Reimplemented by: chronon::Connection::registerProducerThread, chronon::sender::Connection::registerProducerThread

Register a stable producer key for MPSC mode.

function registerOnDestMPSC

virtual class IArbitratablePort * registerOnDestMPSC() =0

Reimplemented by: chronon::Connection::registerOnDestMPSC, chronon::sender::Connection::registerOnDestMPSC

Register this MPSC connection on its destination InPort and return the InPort's type-erased IArbitratablePort interface so the TickSimulation can drive cycle-boundary arbitration without ever knowing the Connection's message type. Returns nullptr when the connection is not in MPSC mode.

function optimizeForSameThread

virtual void optimizeForSameThread() =0

Reimplemented by: chronon::Connection::optimizeForSameThread, chronon::sender::Connection::optimizeForSameThread

Optimize destination port for same-thread access.

Switches InPort to use lock-free SingleThreadMessageQueue. Call this during initialization when both source and destination are determined to be on the same thread (same cluster).

This keeps intra-cluster registered edges on the cheapest storage.

function optimizeForSPSC

virtual void optimizeForSPSC() =0

Reimplemented by: chronon::Connection::optimizeForSPSC, chronon::sender::Connection::optimizeForSPSC

Optimize destination port for cross-thread SPSC access.

Switches InPort to use lock-free LockFreeMessageQueue. Call this during initialization when there is exactly ONE source thread writing to the destination port on a different thread.

function optimizeForMPSC

virtual void optimizeForMPSC() =0

Reimplemented by: chronon::Connection::optimizeForMPSC, chronon::sender::Connection::optimizeForMPSC

Optimize destination port for cross-thread MPSC access.

Switches InPort to use MultiProducerQueueAdapter with one producer queue per Connection.

function minStagedArrivalCycle

inline virtual std::optional< uint64_t > minStagedArrivalCycle() const

Earliest arrival currently staged on this MPSC connection, if any.

Reimplemented by: chronon::Connection::minStagedArrivalCycle, chronon::sender::Connection::minStagedArrivalCycle

function isTight

inline bool isTight() const

True if this is a zero-delay (tight) connection.

function hasThreadQueueId

virtual bool hasThreadQueueId() const =0

True if this connection uses thread-specific queue (MPSC mode).

Reimplemented by: chronon::Connection::hasThreadQueueId, chronon::sender::Connection::hasThreadQueueId

function ensureEpochFreeHeadroom

virtual bool ensureEpochFreeHeadroom(
uint32_t max_lookahead_cycles
) =0

Reimplemented by: chronon::Connection::ensureEpochFreeHeadroom, chronon::sender::Connection::ensureEpochFreeHeadroom

Try to grow physical lock-free buffers enough for epoch-free run-ahead when the model-visible registered edge is unbounded. A finite declared edge capacity is semantic backpressure and must not be bypassed by resizing the storage ring.

function destination

virtual Unit * destination() const =0

Reimplemented by: chronon::Connection::destination, chronon::sender::Connection::destination

function destPortPtr

virtual void * destPortPtr() const =0

Reimplemented by: chronon::Connection::destPortPtr, chronon::sender::Connection::destPortPtr

function delay

virtual uint32_t delay() const =0

Reimplemented by: chronon::Connection::delay, chronon::sender::Connection::delay

function crossThreadHeadroom

inline virtual size_t crossThreadHeadroom() const

Reimplemented by: chronon::Connection::crossThreadHeadroom, chronon::sender::Connection::crossThreadHeadroom

Max producer run-ahead (in cycles) this connection's cross-thread buffer (MPSC staging ring or SPSC lock-free ring) can absorb while the epoch-free path keeps results identical to the reference: roughly threshold / rate - delay + 1, where threshold is the entry count at which transfer() stops accepting (the ring, or the InPort capacity if smaller), rate is the source's per-cycle send cap, and delay accounts for not-yet-due entries the consumer cannot drain. Returns SIZE_MAX for connections with no bounded cross-thread ring (same-thread / unbounded) and 0 when no finite capacity dependency is provably safe. Used to gate the epoch-free lookahead path, which removes the per-epoch drain.

function connId

virtual uint32_t connId() const =0

Reimplemented by: chronon::Connection::connId, chronon::sender::Connection::connId

function configureRegisteredEdge

virtual void configureRegisteredEdge(
std::optional< size_t > capacity,
std::optional< size_t > rate
) =0

Reimplemented by: chronon::Connection::configureRegisteredEdge, chronon::sender::Connection::configureRegisteredEdge

Configure the registered edge modeled by this connection. capacity is the number of entries the producer may have in flight on this edge; rate is the maximum entries this edge can accept per producer cycle.

function cancelInFlight

virtual void cancelInFlight() =0

Reimplemented by: chronon::Connection::cancelInFlight, chronon::sender::Connection::cancelInFlight

Cancel all in-flight messages on this connection.

Advances the cancellation epoch so pending messages are dropped when the receiver tries to consume them.

function arbitrateAdmitErased

virtual size_t arbitrateAdmitErased(
size_t budget
) =0

Reimplemented by: chronon::Connection::arbitrateAdmitErased, chronon::sender::Connection::arbitrateAdmitErased

Type-erased MPSC admission helper. Called by the destination InPort's arbiter at cycle boundary. Pops up to budget entries from the per-connection staging ring and forwards them into the shared queue in FIFO order. Returns the number of entries admitted. Stops on the first forwarding failure (physical ring full, extremely rare).

Only the MPSC path uses staging; non-MPSC connections return 0.

function arbitrateAdmitBoundedErased

virtual size_t arbitrateAdmitBoundedErased(
size_t budget,
uint64_t max_send_cycle
) =0

Reimplemented by: chronon::Connection::arbitrateAdmitBoundedErased, chronon::sender::Connection::arbitrateAdmitBoundedErased

Cycle-bounded MPSC admission. Drains up to budget entries whose enqueue_cycle <= max_send_cycle. Used by consumer-tick-driven arbitration under the lookahead scheduler: the consumer passes S = min(predecessor-thread completed_cycle) so that only entries every producer has already published are admitted. See docs/mpsc-atomic-publish.md.


Updated on 2026-07-06 at 09:03:33 +0000