![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <CircularQueue.h>
Public Types | |
| using | FElementType = T |
Public Member Functions | |
| TCircularQueue (uint32 CapacityPlusOne) | |
| uint32 | Count () const |
| bool | Dequeue (FElementType &OutElement) |
| bool | Dequeue () |
| void | Empty () |
| bool | Enqueue (const FElementType &Element) |
| bool | Enqueue (FElementType &&Element) |
| UE_FORCEINLINE_HINT bool | IsEmpty () const |
| bool | IsFull () const |
| bool | Peek (FElementType &OutItem) const |
| const FElementType * | Peek () const |
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.
| T | The type of elements held in the queue. |
| using TCircularQueue< T >::FElementType = T |
|
inlineexplicit |
Constructor.
| CapacityPlusOne | The number of elements that the queue can hold (will be rounded up to the next power of 2). |
|
inline |
Gets the number of elements in the queue.
Can be called from any thread. The result reflects the calling thread's current view. Since no locking is used, different threads may return different results.
|
inline |
Removes an item from the front of the queue.
|
inline |
Removes an item from the front of the queue.
| OutElement | Will contain the element if the queue is not empty. |
|
inline |
|
inline |
Adds an item to the end of the queue.
| Element | The element to add. |
|
inline |
Adds an item to the end of the queue.
| Element | The element to add. |
|
inline |
|
inline |
Checks whether the queue is full.
Can be called from any thread. The result reflects the calling thread's current view. Since no locking is used, different threads may return different results.
|
inline |
Returns the oldest item in the queue without removing it.
|
inline |
Returns the oldest item in the queue without removing it.
| OutItem | Will contain the item if the queue is not empty. |