Single-producer, single-consumer (SPSC) lock-free queue with integrated or owned storage, equivalent to pw::FixedQueue.
When kInlineCapacity is specified, FixedLockFreeSpscQueue statically allocates its storage buffer inline. When kInlineCapacity is omitted (or set to containers::kExternalStorage), the external-storage specialization is used, which supports dynamic allocation via Allocate() / TryAllocate(), ownership transfer via WithStorage(), or unowned external buffers. Both specializations inherit from LockFreeSpscQueue<T, SizeType> and can be used through a capacity-erased LockFreeSpscQueue<T, SizeType>& reference.
| T | The type of elements stored in the queue. |
| kInlineCapacity | The maximum number of elements the queue can hold. If set to containers::kExternalStorage, the queue storage will be outside the object. |
| SizeType | Unsigned integer type used to store sizes and indices. |
Public Member Functions | |
| constexpr | FixedLockFreeSpscQueue () noexcept |
| FixedLockFreeSpscQueue (const FixedLockFreeSpscQueue &)=delete | |
| FixedLockFreeSpscQueue & | operator= (const FixedLockFreeSpscQueue &)=delete |
| FixedLockFreeSpscQueue (FixedLockFreeSpscQueue &&other) noexcept | |
| FixedLockFreeSpscQueue & | operator= (FixedLockFreeSpscQueue &&other) noexcept |
| template<size_t kOtherCapacity, typename = std::enable_if_t<(kOtherCapacity < kInlineCapacity)>> | |
| FixedLockFreeSpscQueue (FixedLockFreeSpscQueue< T, kOtherCapacity, SizeType > &&other) noexcept | |
| template<size_t kOtherCapacity, typename = std::enable_if_t<(kOtherCapacity < kInlineCapacity)>> | |
| FixedLockFreeSpscQueue & | operator= (FixedLockFreeSpscQueue< T, kOtherCapacity, SizeType > &&other) noexcept |
| constexpr Deallocator * | deallocator () const noexcept |
Public Member Functions inherited from pw::LockFreeSpscQueue< T, SizeType > | |
| constexpr | LockFreeSpscQueue (span< std::byte > unaligned_buffer) noexcept |
| template<size_t kAlignment, size_t kSizeBytes> | |
| constexpr | LockFreeSpscQueue (containers::Storage< kAlignment, kSizeBytes > &storage) noexcept |
| LockFreeSpscQueue (const LockFreeSpscQueue &)=delete | |
| LockFreeSpscQueue & | operator= (const LockFreeSpscQueue &)=delete |
| LockFreeSpscQueue (LockFreeSpscQueue &&)=delete | |
| LockFreeSpscQueue & | operator= (LockFreeSpscQueue &&)=delete |
| ~LockFreeSpscQueue () | |
| reference | front () |
| const_reference | front () const |
| pointer | try_peek () noexcept |
| const_pointer | try_peek () const noexcept |
| bool | empty () const noexcept |
| bool | full () const noexcept |
| size_type | size () const noexcept |
| constexpr size_type | capacity () const noexcept |
| constexpr size_type | max_size () const noexcept |
| size_type | remaining_capacity () const noexcept |
| void | clear () noexcept |
| void | push (const value_type &value) |
| void | push (value_type &&value) |
| bool | try_push (const value_type &value) |
| bool | try_push (value_type &&value) |
| template<typename... Args> | |
| void | emplace (Args &&... args) |
| template<typename... Args> | |
| bool | try_emplace (Args &&... args) |
| void | pop () |
| std::optional< value_type > | try_pop () |
| bool | try_pop (value_type &out) |
| WriteTransaction | BeginWrite () noexcept |
| ReadTransaction | BeginRead () noexcept |
| size_type | push_some (span< const value_type > items) |
| size_type | move_push_some (span< value_type > items) |
| bool | try_push_all (span< const value_type > items) |
| bool | try_move_push_all (span< value_type > items) |
| size_type | pop_some (span< value_type > dest) |
| size_type | pop_n (size_type count) noexcept |
Additional Inherited Members | |
Public Types inherited from pw::LockFreeSpscQueue< T, SizeType > | |
| using | value_type = T |
| The type of elements stored in the queue. | |
| using | size_type = SizeType |
| Unsigned integer type used for indexing and sizes. | |
| using | difference_type = ptrdiff_t |
| Signed integer type for pointer differences. | |
| using | reference = value_type & |
| Mutable reference to an element. | |
| using | const_reference = const value_type & |
| Const reference to an element. | |
| using | pointer = value_type * |
| Pointer to an element. | |
| using | const_pointer = const value_type * |
| Const pointer to an element. | |
Static Public Attributes inherited from pw::LockFreeSpscQueue< T, SizeType > | |
| static constexpr size_type | kMaxCapacity |
|
inlineconstexprnoexcept |
Constructs an empty FixedLockFreeSpscQueue with internal, statically allocated storage.
|
inlinenoexcept |
Move-constructs a FixedLockFreeSpscQueue from another queue of equal capacity.
*this nor other may be accessed concurrently during the move.| [in] | other | The queue to move elements from. |
|
inlinenoexcept |
Move-constructs from a FixedLockFreeSpscQueue of smaller inline capacity.
*this nor other may be accessed concurrently during the move.| [in] | other | The queue to move elements from. |
|
inlineconstexprnoexcept |
Returns nullptr; a FixedLockFreeSpscQueue with static storage never allocates.
|
inlinenoexcept |
Move-assigns a FixedLockFreeSpscQueue from another queue of equal capacity.
*this nor other may be accessed concurrently during the move.| [in] | other | The queue to move elements from. |
*this.
|
inlinenoexcept |
Move-assigns from a FixedLockFreeSpscQueue of smaller inline capacity.
*this nor other may be accessed concurrently during the move.| [in] | other | The queue to move elements from. |
*this.