11#include "libxr_def.hpp"
34 std::make_signed_t<SequenceType>;
72 [[nodiscard]]
size_t MaxSize()
const {
return capacity_; }
86 [[nodiscard]]
size_t Size()
const;
96 [[nodiscard]]
size_t ElementSize()
const {
return element_size_; }
100 struct alignas(LibXR::CONCURRENCY_ALIGNMENT) SequenceCell
102 std::atomic<SequenceType>
107 [[nodiscard]]
void* PayloadPtr(
size_t index);
110 [[nodiscard]]
const void* PayloadPtr(
size_t index)
const;
112 [[nodiscard]]
static size_t AlignUpChecked(
size_t value,
size_t align);
114 [[nodiscard]]
static size_t MultiplyChecked(
size_t lhs,
size_t rhs);
119 static constexpr size_t PAYLOAD_ALLOC_ALIGN =
120 std::max(
alignof(
size_t),
alignof(std::max_align_t));
131 const size_t element_size_;
132 const size_t capacity_;
133 const size_t payload_stride_;
135 SequenceCell* sequences_;
136 std::byte* payloads_;
有界 MPMC 字节队列内核 / Bounded MPMC byte-queue core
MPMCQueueBase(size_t element_size, size_t capacity)
构造一个字节队列内核 / Construct one byte-queue core
size_t EmptySize() const
获取剩余空槽数 / Get the current free-slot count
std::make_signed_t< SequenceType > SequenceDiffType
size_t Size() const
获取并发快照下的当前元素数 / Get the current approximate element count
ErrorCode PopBytes(void *value=nullptr)
按字节出队一个 payload;传空指针时只丢弃队头元素 / Dequeue one payload by bytes; pass null to discard the front item only
size_t ElementSize() const
获取单个 payload 的字节数 / Get the byte size of one payload
~MPMCQueueBase()
析构字节队列内核 / Destroy the byte-queue core
size_t MaxSize() const
获取队列最大容量 / Get the maximum queue capacity
size_t SequenceType
单调递增的逻辑序号类型 / Monotonic logical sequence type.
ErrorCode PushBytes(const void *value)
按字节入队一个 payload / Enqueue one payload by bytes
LibXR 命名空间 / LibXR namespace.
ErrorCode
定义错误码枚举 / Defines an enumeration for error codes
constexpr size_t CONCURRENCY_ALIGNMENT
并发结构对齐粒度(用于降低多核伪共享) / Alignment policy used by concurrency-oriented structures