Skip to main content

chronon::sender::LockFreeMessageQueue

More...

#include <MessageQueue.hpp>

Public Functions

Name
booltryPush(T data, uint64_t arrive_cycle, uint32_t sender_id =0)
std::optional< T >tryPop(uint64_t current_cycle)
size_tsize() const
std::optional< std::pair< uint64_t, uint32_t > >peekHead() const
std::optional< uint64_t >minArrivalCycle() const
boolfull() const
boolempty() const
voidclear()
size_tavailable() const
LockFreeMessageQueue()

Public Attributes

Name
size_tUSABLE_CAPACITY
size_tCAPACITY

Detailed Description

template <typename T >
class chronon::sender::LockFreeMessageQueue;

LockFreeMessageQueue - Single-producer single-consumer message queue.

Optimized for the common case of one sender and one receiver. Uses atomic operations for lock-free operation.

Public Functions Documentation

function tryPush

inline bool tryPush(
T data,
uint64_t arrive_cycle,
uint32_t sender_id =0
)

Parameters:

  • sender_id Stable producer identifier (Connection::conn_id on the MPSC path). Used by MultiProducerQueueAdapter as a cross-run-stable tiebreak key in k-way merge, replacing the partition-dependent queue_id. Zero (default) for single-producer paths where tiebreak is irrelevant.

Return: true if successful, false if queue is full

Push a message (producer only).

function tryPop

inline std::optional< T > tryPop(
uint64_t current_cycle
)

Parameters:

  • current_cycle The current simulation cycle

Return: The message data if available, std::nullopt otherwise

Try to pop a ready message (consumer only).

function size

inline size_t size() const

function peekHead

inline std::optional< std::pair< uint64_t, uint32_t > > peekHead() const

Peek head's (arrive_cycle, sender_id). Used by k-way merge to pick the globally-earliest message with a topology-stable tiebreak.

function minArrivalCycle

inline std::optional< uint64_t > minArrivalCycle() const

Peek at the minimum arrival cycle.

function full

inline bool full() const

function empty

inline bool empty() const

function clear

inline void clear()

Clear all pending messages (consumer-side).

Drops all in-flight items currently visible in the queue by advancing head to the current tail.

function available

inline size_t available() const

function LockFreeMessageQueue

inline LockFreeMessageQueue()

Public Attributes Documentation

variable USABLE_CAPACITY

static size_t USABLE_CAPACITY = CAPACITY - 1;

variable CAPACITY

static size_t CAPACITY = 4096;

Updated on 2026-05-26 at 05:42:32 +0000