Navigation
API > API/Runtime > API/Runtime/Core
Fast single-producer/single-consumer unbounded concurrent queue. Doesn't free memory until destruction but recycles consumed items. Based on http://www.1024cores.net/home/lock-free-algorithms/queues/unbounded-spsc-queue
| Name | TSpscQueue |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/SpscQueue.h |
| Include Path | #include "Containers/SpscQueue.h" |
Syntax
template<typename T, typename AllocatorType>
class TSpscQueue
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TSpscQueue () |
Containers/SpscQueue.h | ||
TSpscQueue
(
TSpscQueue&& |
Containers/SpscQueue.h | ||
TSpscQueue
(
const TSpscQueue& |
Containers/SpscQueue.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~TSpscQueue() |
Containers/SpscQueue.h |
Structs
| Name | Remarks |
|---|---|
| FIterator | Allows the single consumer to iterate the contents of the queue without popping from it. |
| FNode |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ElementType | T | Containers/SpscQueue.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| First | FNode * | Containers/SpscQueue.h | ||
| Head | FNode * | Producer part accessed only by producer | Containers/SpscQueue.h | |
| NumElems | std::atomic< int32 > | Containers/SpscQueue.h | ||
| Tail | std::atomic< FNode * > | Consumer part accessed mainly by consumer, infrequently by producer | Containers/SpscQueue.h | |
| TailCopy | FNode * | Containers/SpscQueue.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FIterator begin() |
Containers/SpscQueue.h | ||
| Returns empty TOptional if queue is empty | Containers/SpscQueue.h | ||
bool Dequeue
(
ElementType& OutElem |
Containers/SpscQueue.h | ||
std::nullptr_t end() |
Containers/SpscQueue.h | ||
void Enqueue
(
ArgTypes&&... Args |
Containers/SpscQueue.h | ||
bool IsEmpty() |
Containers/SpscQueue.h | ||
int32 Num() |
Containers/SpscQueue.h | ||
ElementType * Peek () |
As there can be only one consumer, a consumer can safely "peek" the tail of the queue. | Containers/SpscQueue.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TSpscQueue & operator=
(
const TSpscQueue& |
Containers/SpscQueue.h | ||
TSpscQueue & operator=
(
TSpscQueue&& |
Containers/SpscQueue.h |