libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::MPMCQueue< Payload > Class Template Referencefinal

带固定 payload 类型的有界 MPMC 队列。 More...

#include <mpmc_queue.hpp>

Inheritance diagram for LibXR::MPMCQueue< Payload >:
[legend]
Collaboration diagram for LibXR::MPMCQueue< Payload >:
[legend]

Public Types

using ValueType = Payload
 仅接受平凡可拷贝 payload。 Accepts only trivially copyable payloads.
 
- Public Types inherited from LibXR::QueueTypedBase< MPMCQueue< Payload >, Payload >
using ValueType
 队列元素类型。 Queue element type.
 
- Public Types inherited from LibXR::MPMCQueueBase
using SequenceType = size_t
 单调递增的逻辑序号类型 / Monotonic logical sequence type.
 
using SequenceDiffType
 序号差值判定类型 / Signed type used for sequence-delta checks.
 

Public Member Functions

 MPMCQueue (size_t capacity)
 构造一个 MPMC 队列。
 
- Public Member Functions inherited from LibXR::QueueTypedBase< MPMCQueue< Payload >, Payload >
ErrorCode Push (const Payload &item)
 推入一个强类型元素。
 
ErrorCode Pop (Payload &item)
 弹出一个强类型元素。
 
ErrorCode Pop ()
 丢弃一个队头元素。
 
- Public Member Functions inherited from LibXR::MPMCQueueBase
 MPMCQueueBase (size_t element_size, size_t capacity)
 构造一个字节队列内核 / Construct one byte-queue core
 
 ~MPMCQueueBase ()
 析构字节队列内核 / Destroy the byte-queue core
 
ErrorCode PushBytes (const void *value)
 按字节入队一个 payload / Enqueue one payload by bytes
 
ErrorCode PopBytes (void *value=nullptr)
 按字节出队一个 payload;传空指针时只丢弃队头元素 / Dequeue one payload by bytes; pass null to discard the front item only
 
size_t MaxSize () const
 获取队列最大容量 / Get the maximum queue capacity
 
size_t Size () const
 获取并发快照下的当前元素数 / Get the current approximate element count
 
size_t EmptySize () const
 获取剩余空槽数 / Get the current free-slot count
 
size_t ElementSize () const
 获取单个 payload 的字节数 / Get the byte size of one payload
 

Detailed Description

template<typename Payload>
class LibXR::MPMCQueue< Payload >

带固定 payload 类型的有界 MPMC 队列。

Bounded MPMC queue with a fixed payload type.

队列内部只把 payload 当成原始字节块搬运,不会在内部形成 Payload* 指针, 因此 Payload 的对齐要求不会额外约束队列内部字节缓冲区的语义边界。

The queue moves payloads only as raw byte blocks and never forms internal Payload* pointers, so Payload alignment does not add an extra semantic constraint on the internal byte-buffer contract.

Template Parameters
Payload队列存储的数据类型。 Queue element type.

Definition at line 26 of file mpmc_queue.hpp.

Member Typedef Documentation

◆ ValueType

template<typename Payload >
using LibXR::MPMCQueue< Payload >::ValueType = Payload

仅接受平凡可拷贝 payload。 Accepts only trivially copyable payloads.

仅接受平凡可析构 payload。 Accepts only trivially destructible payloads. 队列元素类型。 Queue element type.

Definition at line 37 of file mpmc_queue.hpp.

Constructor & Destructor Documentation

◆ MPMCQueue()

template<typename Payload >
LibXR::MPMCQueue< Payload >::MPMCQueue ( size_t capacity)
inlineexplicit

构造一个 MPMC 队列。

Construct one MPMC queue.

Parameters
capacity队列容量。 Queue capacity.
Note
包含动态内存分配。 Contains dynamic memory allocation.

Definition at line 50 of file mpmc_queue.hpp.

51 : MPMCQueueBase(sizeof(Payload), capacity)
52 {
53 }
MPMCQueueBase(size_t element_size, size_t capacity)
构造一个字节队列内核 / Construct one byte-queue core

The documentation for this class was generated from the following file: