Skip to main content

DirectSPSCQueueAdapter

More...

#include <DirectSPSCQueueAdapter.hpp>

Inherits from IMessageQueue< T >

Public Functions

Name
std::optional< T >tryPop(uint64_t current_cycle) override
size_tstorageCapacity() const override
size_tsize() const override
voidsetCapacity(size_t capacity) override
boolpushDirect(T && data, uint64_t arrive_cycle)
boolpush(T data, uint64_t arrive_cycle) override
voidpopAllInto(std::vector< T > & out, uint64_t current_cycle) override
std::vector< T >popAll(uint64_t current_cycle) override
T *peekReady(uint64_t current_cycle)
std::optional< uint64_t >minArrivalCycle() const override
boolhasReady(uint64_t current_cycle) const override
boolfull() const override
boolempty() const override
template <typename Visitor >
bool
consumeReady(uint64_t current_cycle, Visitor && visitor)
voidconsumePeeked(uint64_t current_cycle)
voidclear() override
size_tcapacity() const override
size_tavailable() const override
size_tadmissionOccupancy(uint64_t send_cycle) const override
std::optional< uint64_t >admissionMinArrivalCycle(uint64_t send_cycle) const override
DirectSPSCQueueAdapter(size_t capacity =LockFreeMessageQueue< T >::USABLE_CAPACITY, size_t min_usable_capacity =0)

Detailed Description

template <typename T >
class DirectSPSCQueueAdapter;

DirectSPSCQueueAdapter - Experimental registered-edge SPSC backend.

Unlike LockFreeQueueAdapter, the physical queue and the admission ledger share one monotonic producer ticket. A successful release-store of tail_ticket_ therefore both publishes the payload and accounts for the architectural push, avoiding the second locked RMW in the legacy adapter. InPort may also push and consume the stored envelope directly, avoiding the extra by-value virtual-interface hops on the common one-message path.

The consumer still publishes each pop in three ordered stages required by same-cycle registered-edge admission:

  1. arrival metadata, 2. reusable queue head, 3. admission credit. A pop at cycle C is consequently not admission credit until cycle C + 1.

Public Functions Documentation

function tryPop

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

function storageCapacity

inline size_t storageCapacity() const override

function size

inline size_t size() const override

function setCapacity

inline void setCapacity(
size_t capacity
) override

function pushDirect

inline bool pushDirect(
T && data,
uint64_t arrive_cycle
)

Producer-only direct path used by InPort after backend selection.

function push

inline bool push(
T data,
uint64_t arrive_cycle
) override

function popAllInto

inline void popAllInto(
std::vector< T > & out,
uint64_t current_cycle
) override

function popAll

inline std::vector< T > popAll(
uint64_t current_cycle
) override

function peekReady

inline T * peekReady(
uint64_t current_cycle
)

Consumer-only ready-entry view. The returned pointer remains owned by the consumer until consumePeeked() publishes the new head. This split lets typed InPort paths decide cancellation before constructing a large optional return object.

function minArrivalCycle

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

function hasReady

inline bool hasReady(
uint64_t current_cycle
) const override

function full

inline bool full() const override

function empty

inline bool empty() const override

function consumeReady

template <typename Visitor >
inline bool consumeReady(
uint64_t current_cycle,
Visitor && visitor
)

Consumer-only direct path. The visitor runs while the slot is owned by the consumer and may move from or discard the payload. Returning true means one ready entry was consumed, even if the visitor discarded it.

function consumePeeked

inline void consumePeeked(
uint64_t current_cycle
)

Publish consumption of the ready entry returned by peekReady().

function clear

inline void clear() override

function capacity

inline size_t capacity() const override

function available

inline size_t available() const override

function admissionOccupancy

inline size_t admissionOccupancy(
uint64_t send_cycle
) const override

function admissionMinArrivalCycle

inline std::optional< uint64_t > admissionMinArrivalCycle(
uint64_t send_cycle
) const override

function DirectSPSCQueueAdapter

inline explicit DirectSPSCQueueAdapter(
size_t capacity =LockFreeMessageQueue< T >::USABLE_CAPACITY,
size_t min_usable_capacity =0
)

Updated on 2026-07-16 at 14:00:05 +0000