Skip to main content

chronon::sender::LockFreeMessageQueue

More...

#include <MessageQueue.hpp>

Public Functions

Name
size_tusableCapacity() const
booltryPush(T data, uint64_t arrive_cycle, uint32_t sender_id =0)
template <typename BeforeRelease ,typename AfterRelease >
std::optional< T >
tryPopWithReleaseCallbacks(uint64_t current_cycle, BeforeRelease && before_release, AfterRelease && after_release)
template <typename AfterRelease >
std::optional< T >
tryPopAfterRelease(uint64_t current_cycle, AfterRelease && after_release)
std::optional< T >tryPop(uint64_t current_cycle)
size_tsize() const
size_tphysicalCapacityForUserCapacity(size_t user_capacity)
std::optional< std::pair< uint64_t, uint32_t > >peekHead() const
std::optional< uint64_t >minArrivalCycle() const
boolfull() const
boolempty() const
voidclear()
size_tcapacity() const
size_tavailable() const
LockFreeMessageQueue(size_t physical_capacity =CAPACITY)

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 usableCapacity

inline size_t usableCapacity() const

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 tryPopWithReleaseCallbacks

template <typename BeforeRelease ,
typename AfterRelease >
inline std::optional< T > tryPopWithReleaseCallbacks(
uint64_t current_cycle,
BeforeRelease && before_release,
AfterRelease && after_release
)

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 tryPopAfterRelease

template <typename AfterRelease >
inline std::optional< T > tryPopAfterRelease(
uint64_t current_cycle,
AfterRelease && after_release
)

function tryPop

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

function size

inline size_t size() const

function physicalCapacityForUserCapacity

static inline size_t physicalCapacityForUserCapacity(
size_t user_capacity
)

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 capacity

inline size_t capacity() const

function available

inline size_t available() const

function LockFreeMessageQueue

inline explicit LockFreeMessageQueue(
size_t physical_capacity =CAPACITY
)

Public Attributes Documentation

variable USABLE_CAPACITY

static size_t USABLE_CAPACITY = CAPACITY - 1;

variable CAPACITY

static size_t CAPACITY = 4096;

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