TCircularQueue

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

Windows
MacOS
Linux

References

Module

Core

Header

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

Include

#include "Containers/CircularQueue.h"

Syntax

template<typename ElementType>
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.

To be called only from consumer thread.

Public function

bool

 

Dequeue

(
    ElementType& OutElement
)

Removes an item from the front of the queue.

To be called only from consumer thread.

Public function

void

 

Empty()

Empties the queue.

To be called only from consumer thread.

Public function

bool

 

Enqueue

(
    const ElementType& Element
)

Adds an item to the end of the queue.

To be called only from producer thread.

Public function

bool

 

Enqueue

(
    ElementType&& Element
)

Adds an item to the end of the queue.

To be called only from producer thread.

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 Elemen...

 

Peek()

Returns the oldest item in the queue without removing it.

Public function Const

bool

 

Peek

(
    ElementType& OutItem
)

Returns the oldest item in the queue without removing it.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss