Navigation
API > API/Runtime > API/Runtime/Core
Implements a lock-free first-in first-out queue using a circular array.
This class is thread safe only in single-producer single-consumer scenarios.
The number of items that can be enqueued is one less than the queue's capacity, because one item will be used for detecting full and empty states.
There is some room for optimization via using fine grained memory fences, but the implications for all of our target platforms need further analysis, so we're using the simpler sequentially consistent model for now.
| Name | TCircularQueue |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/CircularQueue.h |
| Include Path | #include "Containers/CircularQueue.h" |
Syntax
template<typename T>
class TCircularQueue
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TCircularQueue
(
uint32 CapacityPlusOne |
Constructor. | Containers/CircularQueue.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FElementType | T | Containers/CircularQueue.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Buffer | TCircularBuffer< FElementType > | Holds the buffer. | Containers/CircularQueue.h | |
| Head | TAtomic< uint32 > | Holds the index to the first item in the buffer. | Containers/CircularQueue.h | |
| Tail | TAtomic< uint32 > | Holds the index to the last item in the buffer. | Containers/CircularQueue.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
uint32 Count () |
Gets the number of elements in the queue. | Containers/CircularQueue.h | |
bool Dequeue () |
Removes an item from the front of the queue.To be called only from consumer thread. | Containers/CircularQueue.h | |
bool Dequeue
(
FElementType& OutElement |
Removes an item from the front of the queue.To be called only from consumer thread. | Containers/CircularQueue.h | |
void Empty () |
Empties the queue.To be called only from consumer thread. | Containers/CircularQueue.h | |
bool Enqueue
(
const FElementType& Element |
Adds an item to the end of the queue.To be called only from producer thread. | Containers/CircularQueue.h | |
bool Enqueue
(
FElementType&& Element |
Adds an item to the end of the queue.To be called only from producer thread. | Containers/CircularQueue.h | |
bool IsEmpty () |
Checks whether the queue is empty. | Containers/CircularQueue.h | |
bool IsFull () |
Checks whether the queue is full. | Containers/CircularQueue.h | |
const FElementType * Peek () |
Returns the oldest item in the queue without removing it. | Containers/CircularQueue.h | |
bool Peek
(
FElementType& OutItem |
Returns the oldest item in the queue without removing it. | Containers/CircularQueue.h |