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
Source unit (for dependency analysis).
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
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 Unit *destination() const =0
Destination unit (for dependency analysis).
virtual void *destPortPtr() const =0
Destination port pointer (type-erased) for port-level grouping.
virtual uint32_tdelay() const =0
Delay in cycles between push and arrival.
virtual uint32_tconnId() const =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

Source unit (for dependency analysis).

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's source thread

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 (multiple source threads writing to it). All connections from the same source thread share the same queue_id.

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:

  • thread_id Source thread identifier

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

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

Register a producer thread 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 eliminates mutex overhead (~18% of execution time) for intra-cluster connections.

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 per-thread producer queues.

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 destination

virtual Unit * destination() const =0

Destination unit (for dependency analysis).

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

function destPortPtr

virtual void * destPortPtr() const =0

Destination port pointer (type-erased) for port-level grouping.

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

function delay

virtual uint32_t delay() const =0

Delay in cycles between push and arrival.

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

function connId

virtual uint32_t connId() const =0

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

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-05-26 at 05:42:32 +0000