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

Template for queues. 更多...

#include <Queue.h>

Public 成员函数

bool Dequeue (ItemType &OutItem)
 Removes and returns the item from the tail of the queue. 更多...
 
void Empty ()
 Empty the queue, discarding all items. 更多...
 
bool Enqueue (const ItemType &Item)
 Adds an item to the head of the queue. 更多...
 
bool Enqueue (ItemType &&Item)
 Adds an item to the head of the queue. 更多...
 
bool IsEmpty () const
 Checks whether the queue is empty. 更多...
 
ItemType * Peek ()
 Peek at the queue's tail item without removing it. 更多...
 
bool Peek (ItemType &OutItem) const
 Peeks at the queue's tail item without removing it. 更多...
 
bool Pop ()
 Removes the item from the tail of the queue. 更多...
 
 TQueue ()
 Default constructor.
 
 ~TQueue ()
 Destructor.
 

详细描述

template<typename ItemType, EQueueMode Mode = EQueueMode::Spsc>
class TQueue< ItemType, Mode >

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.

参数
ItemTypeThe type of items stored in the queue.
ModeThe queue mode (single-producer, single-consumer by default).
待办事项:
gmp: Implement node pooling.

成员函数说明

◆ Dequeue()

template<typename ItemType , EQueueMode Mode = EQueueMode::Spsc>
bool TQueue< ItemType, Mode >::Dequeue ( ItemType &  OutItem)
inline

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

参数
OutValueWill hold the returned value.
返回
true if a value was returned, false if the queue was empty.
注解
To be called only from consumer thread.
参见
Empty, Enqueue, IsEmpty, Peek, Pop

◆ Empty()

template<typename ItemType , EQueueMode Mode = EQueueMode::Spsc>
void TQueue< ItemType, Mode >::Empty ( )
inline

Empty the queue, discarding all items.

注解
To be called only from consumer thread.
参见
Dequeue, IsEmpty, Peek, Pop

◆ Enqueue() [1/2]

template<typename ItemType , EQueueMode Mode = EQueueMode::Spsc>
bool TQueue< ItemType, Mode >::Enqueue ( const ItemType &  Item)
inline

Adds an item to the head of the queue.

参数
ItemThe item to add.
返回
true if the item was added, false otherwise.
注解
To be called only from producer thread(s).
参见
Dequeue, Pop

◆ Enqueue() [2/2]

template<typename ItemType , EQueueMode Mode = EQueueMode::Spsc>
bool TQueue< ItemType, Mode >::Enqueue ( ItemType &&  Item)
inline

Adds an item to the head of the queue.

参数
ItemThe item to add.
返回
true if the item was added, false otherwise.
注解
To be called only from producer thread(s).
参见
Dequeue, Pop

◆ IsEmpty()

template<typename ItemType , EQueueMode Mode = EQueueMode::Spsc>
bool TQueue< ItemType, Mode >::IsEmpty ( ) const
inline

Checks whether the queue is empty.

返回
true if the queue is empty, false otherwise.
注解
To be called only from consumer thread.
参见
Dequeue, Empty, Peek, Pop

◆ Peek() [1/2]

template<typename ItemType , EQueueMode Mode = EQueueMode::Spsc>
ItemType * TQueue< ItemType, Mode >::Peek ( )
inline

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

This version of Peek allows peeking at a queue of items that do not allow copying, such as TUniquePtr.

返回
Pointer to the item, or nullptr if queue is empty

◆ Peek() [2/2]

template<typename ItemType , EQueueMode Mode = EQueueMode::Spsc>
bool TQueue< ItemType, Mode >::Peek ( ItemType &  OutItem) const
inline

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

参数
OutItemWill hold the peeked at item.
返回
true if an item was returned, false if the queue was empty.
注解
To be called only from consumer thread.
参见
Dequeue, Empty, IsEmpty, Pop

◆ Pop()

template<typename ItemType , EQueueMode Mode = EQueueMode::Spsc>
bool TQueue< ItemType, Mode >::Pop ( )
inline

Removes the item from the tail of the queue.

返回
true if a value was removed, false if the queue was empty.
注解
To be called only from consumer thread.
参见
Dequeue, Empty, Enqueue, IsEmpty, Peek

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