TQueue

Template for queues.

Windows
MacOS
Linux

References

Module

Core

Header

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

Include

#include "Containers/Queue.h"

Syntax

template<typename ItemType, EQueueMode Mode>
class TQueue

Remarks

Template for queues.

This template implements an unbounded non-intrusive queue using a lock-free linked list that stores copies of the queued items. The template can operate in two modes: Multiple-producers single-consumer (MPSC) and Single-producer single-consumer (SPSC).

The queue is thread-safe in both modes. The Dequeue() method ensures thread-safety by writing it in a way that does not depend on possible instruction reordering on the CPU. The Enqueue() method uses an atomic compare-and-swap in multiple-producers scenarios.

Constructors

Name Description

Public function

TQueue()

Default constructor.

Destructors

Name Description

Public function

~TQueue()

Destructor.

Functions

Name Description

Public function

bool

 

Dequeue

(
    ItemType& OutItem
)

Removes and returns the item from the tail of the queue.

To be called only from consumer thread.

Public function

void

 

Empty()

Empty the queue, discarding all items.

To be called only from consumer thread.

Public function

bool

 

Enqueue

(
    const ItemType& Item
)

Adds an item to the head of the queue.

To be called only from producer thread(s).

Public function

bool

 

Enqueue

(
    ItemType&& Item
)

Adds an item to the head of the queue.

To be called only from producer thread(s).

Public function Const

bool

 

IsEmpty()

Checks whether the queue is empty.

To be called only from consumer thread.

Public function

ItemType ...

 

Peek()

Peek at the queue's tail item without removing it.

Public function Const

const ItemTy...

 

Peek()

Public function Const

bool

 

Peek

(
    ItemType& OutItem
)

Peeks at the queue's tail item without removing it.

To be called only from consumer thread.

Public function

bool

 

Pop()

Removes the item from the tail of the queue.

To be called only from consumer thread.

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback