engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 所有成员列表
TCircularQueue< ElementType > 模板类 参考

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

#include <CircularQueue.h>

Public 成员函数

uint32 Count () const
 Gets the number of elements in the queue. 更多...
 
bool Dequeue ()
 Removes an item from the front of the queue. 更多...
 
bool Dequeue (ElementType &OutElement)
 Removes an item from the front of the queue. 更多...
 
void Empty ()
 Empties the queue. 更多...
 
bool Enqueue (const ElementType &Element)
 Adds an item to the end of the queue. 更多...
 
bool Enqueue (ElementType &&Element)
 Adds an item to the end of the queue. 更多...
 
FORCEINLINE bool IsEmpty () const
 Checks whether the queue is empty. 更多...
 
bool IsFull () const
 Checks whether the queue is full. 更多...
 
const ElementType * Peek () const
 Returns the oldest item in the queue without removing it. 更多...
 
bool Peek (ElementType &OutItem) const
 Returns the oldest item in the queue without removing it. 更多...
 
 TCircularQueue (uint32 CapacityPlusOne)
 Constructor. 更多...
 

详细描述

template<typename ElementType>
class TCircularQueue< ElementType >

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.

参数
ElementTypeThe type of elements held in the queue.

构造及析构函数说明

◆ TCircularQueue()

template<typename ElementType >
TCircularQueue< ElementType >::TCircularQueue ( uint32  CapacityPlusOne)
inlineexplicit

Constructor.

参数
CapacityPlusOneThe number of elements that the queue can hold (will be rounded up to the next power of 2).

成员函数说明

◆ Count()

template<typename ElementType >
uint32 TCircularQueue< ElementType >::Count ( ) const
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.

返回
Number of queued elements.

◆ Dequeue() [1/2]

template<typename ElementType >
bool TCircularQueue< ElementType >::Dequeue ( )
inline

Removes an item from the front of the queue.

返回
true if an element has been removed, false if the queue was empty.
注解
To be called only from consumer thread.

◆ Dequeue() [2/2]

template<typename ElementType >
bool TCircularQueue< ElementType >::Dequeue ( ElementType &  OutElement)
inline

Removes an item from the front of the queue.

参数
OutElementWill contain the element if the queue is not empty.
返回
true if an element has been returned, false if the queue was empty.
注解
To be called only from consumer thread.

◆ Empty()

template<typename ElementType >
void TCircularQueue< ElementType >::Empty ( )
inline

Empties the queue.

注解
To be called only from consumer thread.
参见
IsEmpty

◆ Enqueue() [1/2]

template<typename ElementType >
bool TCircularQueue< ElementType >::Enqueue ( const ElementType &  Element)
inline

Adds an item to the end of the queue.

参数
ElementThe element to add.
返回
true if the item was added, false if the queue was full.
注解
To be called only from producer thread.

◆ Enqueue() [2/2]

template<typename ElementType >
bool TCircularQueue< ElementType >::Enqueue ( ElementType &&  Element)
inline

Adds an item to the end of the queue.

参数
ElementThe element to add.
返回
true if the item was added, false if the queue was full.
注解
To be called only from producer thread.

◆ IsEmpty()

template<typename ElementType >
FORCEINLINE bool TCircularQueue< ElementType >::IsEmpty ( ) const
inline

Checks whether the queue is empty.

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.

返回
true if the queue is empty, false otherwise.
参见
Empty, IsFull

◆ IsFull()

template<typename ElementType >
bool TCircularQueue< ElementType >::IsFull ( ) const
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.

返回
true if the queue is full, false otherwise.
参见
IsEmpty

◆ Peek() [1/2]

template<typename ElementType >
const ElementType * TCircularQueue< ElementType >::Peek ( ) const
inline

Returns the oldest item in the queue without removing it.

返回
an ElementType pointer if an item has been returned, nullptr if the queue was empty.
注解
To be called only from consumer thread.
The return value is only valid until Dequeue, Empty, or the destructor has been called.

◆ Peek() [2/2]

template<typename ElementType >
bool TCircularQueue< ElementType >::Peek ( ElementType &  OutItem) const
inline

Returns the oldest item in the queue without removing it.

参数
OutItemWill contain the item if the queue is not empty.
返回
true if an item has been returned, false if the queue was empty.
注解
To be called only from consumer thread.

该类的文档由以下文件生成: