TCircularQueue

Implements a lock-free first-in first-out queue using a circular array.

Choose your operating system:

Windows

macOS

Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Containers/CircularQueue.h

Include

#include "Containers/CircularQueue.h"

Syntax

template<typename T>
class TCircularQueue

Remarks

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.

Constructors

Name Description

Public function

TCircularQueue

(
    uint32 CapacityPlusOne
)

Constructor.

Functions

Name Description

Public function Const

uint32

 

Count()

Gets the number of elements in the queue.

Public function

bool

 

Dequeue()

Removes an item from the front of the queue.

Public function

bool

 

Dequeue

(
    FElementType& OutElement
)

Removes an item from the front of the queue.

Public function

void

 

Empty()

Empties the queue.

@note To be called only from consumer thread.

Public function

bool

 

Enqueue

(
    const FElementType& Element
)

Adds an item to the end of the queue.

Public function

bool

 

Enqueue

(
    FElementType&& Element
)

Adds an item to the end of the queue.

Public function Const

bool

 

IsEmpty()

Checks whether the queue is empty.

Public function Const

bool

 

IsFull()

Checks whether the queue is full.

Public function Const

const FEleme...

 

Peek()

Returns the oldest item in the queue without removing it.

Public function Const

bool

 

Peek

(
    FElementType& OutItem
)

Returns the oldest item in the queue without removing it.

Typedefs

Name

Description

FElementType