TrinityCore
LockedQueue< T, StorageType > Class Template Reference

#include <LockedQueue.h>

Public Member Functions

 LockedQueue ()
 Create a LockedQueue. More...
 
virtual ~LockedQueue ()
 Destroy a LockedQueue. More...
 
void add (const T &item)
 Adds an item to the queue. More...
 
template<class Iterator >
void readd (Iterator begin, Iterator end)
 Adds items back to front of the queue. More...
 
bool next (T &result)
 Gets the next result in the queue, if any. More...
 
template<class Checker >
bool next (T &result, Checker &check)
 
T & peek (bool autoUnlock=false)
 Peeks at the top of the queue. Check if the queue is empty before calling! Remember to unlock after use if autoUnlock == false. More...
 
void cancel ()
 Cancels the queue. More...
 
bool cancelled ()
 Checks if the queue is cancelled. More...
 
void lock ()
 Locks the queue for access. More...
 
void unlock ()
 Unlocks the queue. More...
 
void pop_front ()
 ! Calls pop_front of the queue More...
 
bool empty ()
 ! Checks if we're empty or not with locks held More...
 

Private Attributes

std::mutex _lock
 Lock access to the queue. More...
 
StorageType _queue
 Storage backing the queue. More...
 
volatile bool _canceled
 Cancellation flag. More...
 

Detailed Description

template<class T, typename StorageType = std::deque<T>>
class LockedQueue< T, StorageType >

Definition at line 25 of file LockedQueue.h.

Constructor & Destructor Documentation

◆ LockedQueue()

template<class T , typename StorageType = std::deque<T>>
LockedQueue< T, StorageType >::LockedQueue ( )
inline

Create a LockedQueue.

Definition at line 39 of file LockedQueue.h.

◆ ~LockedQueue()

template<class T , typename StorageType = std::deque<T>>
virtual LockedQueue< T, StorageType >::~LockedQueue ( )
inlinevirtual

Destroy a LockedQueue.

Definition at line 45 of file LockedQueue.h.

Member Function Documentation

◆ add()

template<class T , typename StorageType = std::deque<T>>
void LockedQueue< T, StorageType >::add ( const T &  item)
inline

Adds an item to the queue.

Definition at line 50 of file LockedQueue.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

template<class T , typename StorageType = std::deque<T>>
void LockedQueue< T, StorageType >::cancel ( )
inline

Cancels the queue.

Definition at line 111 of file LockedQueue.h.

+ Here is the call graph for this function:

◆ cancelled()

template<class T , typename StorageType = std::deque<T>>
bool LockedQueue< T, StorageType >::cancelled ( )
inline

Checks if the queue is cancelled.

Definition at line 119 of file LockedQueue.h.

+ Here is the call graph for this function:

◆ empty()

template<class T , typename StorageType = std::deque<T>>
bool LockedQueue< T, StorageType >::empty ( )
inline

! Checks if we're empty or not with locks held

Definition at line 145 of file LockedQueue.h.

+ Here is the call graph for this function:

◆ lock()

template<class T , typename StorageType = std::deque<T>>
void LockedQueue< T, StorageType >::lock ( )
inline

Locks the queue for access.

Definition at line 126 of file LockedQueue.h.

+ Here is the caller graph for this function:

◆ next() [1/2]

template<class T , typename StorageType = std::deque<T>>
bool LockedQueue< T, StorageType >::next ( T &  result)
inline

Gets the next result in the queue, if any.

Definition at line 68 of file LockedQueue.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ next() [2/2]

template<class T , typename StorageType = std::deque<T>>
template<class Checker >
bool LockedQueue< T, StorageType >::next ( T &  result,
Checker &  check 
)
inline

Definition at line 82 of file LockedQueue.h.

+ Here is the call graph for this function:

◆ peek()

template<class T , typename StorageType = std::deque<T>>
T & LockedQueue< T, StorageType >::peek ( bool  autoUnlock = false)
inline

Peeks at the top of the queue. Check if the queue is empty before calling! Remember to unlock after use if autoUnlock == false.

Definition at line 98 of file LockedQueue.h.

+ Here is the call graph for this function:

◆ pop_front()

template<class T , typename StorageType = std::deque<T>>
void LockedQueue< T, StorageType >::pop_front ( )
inline

! Calls pop_front of the queue

Definition at line 138 of file LockedQueue.h.

+ Here is the call graph for this function:

◆ readd()

template<class T , typename StorageType = std::deque<T>>
template<class Iterator >
void LockedQueue< T, StorageType >::readd ( Iterator  begin,
Iterator  end 
)
inline

Adds items back to front of the queue.

Definition at line 61 of file LockedQueue.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlock()

template<class T , typename StorageType = std::deque<T>>
void LockedQueue< T, StorageType >::unlock ( )
inline

Unlocks the queue.

Definition at line 132 of file LockedQueue.h.

+ Here is the caller graph for this function:

Member Data Documentation

◆ _canceled

template<class T , typename StorageType = std::deque<T>>
volatile bool LockedQueue< T, StorageType >::_canceled
private

Cancellation flag.

Definition at line 34 of file LockedQueue.h.

◆ _lock

template<class T , typename StorageType = std::deque<T>>
std::mutex LockedQueue< T, StorageType >::_lock
private

Lock access to the queue.

Definition at line 28 of file LockedQueue.h.

◆ _queue

template<class T , typename StorageType = std::deque<T>>
StorageType LockedQueue< T, StorageType >::_queue
private

Storage backing the queue.

Definition at line 31 of file LockedQueue.h.


The documentation for this class was generated from the following file: