Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Private Types | Private Attributes | List of all members
cQueue< ItemType, Funcs > Class Template Reference

#include <Queue.h>

Collaboration diagram for cQueue< ItemType, Funcs >:
Collaboration graph
[legend]

Public Member Functions

void BlockTillEmpty (void)
 Blocks until the queue is empty. More...
 
void Clear (void)
 Removes all Items from the Queue, calling Delete on each of them. More...
 
 cQueue ()
 
ItemType DequeueItem (void)
 Dequeues an item from the queue, blocking until an item is available. More...
 
void EnqueueItem (ItemType a_Item)
 Enqueues an item to the queue, may block if other threads are accessing the queue. More...
 
void EnqueueItemIfNotPresent (ItemType a_Item)
 Enqueues an item in the queue if not already present (as determined by operator ==). More...
 
bool Remove (ItemType a_Item)
 Removes the item from the queue. More...
 
template<class Predicate >
void RemoveIf (Predicate a_Predicate)
 Removes all items for which the predicate returns true. More...
 
size_t Size (void)
 Returns the size at time of being called. More...
 
bool TryDequeueItem (ItemType &item)
 Dequeues an item from the queue if any are present. More...
 
 ~cQueue ()
 

Private Types

typedef QueueType::iterator iterator
 
typedef std::list< ItemType > QueueType
 

Private Attributes

QueueType m_Contents
 The contents of the queue. More...
 
cCriticalSection m_CS
 Mutex that protects access to the queue contents. More...
 
cEvent m_evtAdded
 Event that is signalled when an item is added. More...
 
cEvent m_evtRemoved
 Event that is signalled when an item is removed (both dequeued or erased) More...
 

Detailed Description

template<class ItemType, class Funcs = cQueueFuncs<ItemType>>
class cQueue< ItemType, Funcs >

Definition at line 43 of file Queue.h.

Member Typedef Documentation

◆ iterator

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
typedef QueueType::iterator cQueue< ItemType, Funcs >::iterator
private

Definition at line 49 of file Queue.h.

◆ QueueType

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
typedef std::list<ItemType> cQueue< ItemType, Funcs >::QueueType
private

Definition at line 46 of file Queue.h.

Constructor & Destructor Documentation

◆ cQueue()

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
cQueue< ItemType, Funcs >::cQueue ( )
inline

Definition at line 52 of file Queue.h.

◆ ~cQueue()

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
cQueue< ItemType, Funcs >::~cQueue ( )
inline

Definition at line 53 of file Queue.h.

Member Function Documentation

◆ BlockTillEmpty()

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
void cQueue< ItemType, Funcs >::BlockTillEmpty ( void  )
inline

Blocks until the queue is empty.

Definition at line 116 of file Queue.h.

◆ Clear()

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
void cQueue< ItemType, Funcs >::Clear ( void  )
inline

Removes all Items from the Queue, calling Delete on each of them.

Definition at line 128 of file Queue.h.

◆ DequeueItem()

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
ItemType cQueue< ItemType, Funcs >::DequeueItem ( void  )
inline

Dequeues an item from the queue, blocking until an item is available.

Definition at line 100 of file Queue.h.

◆ EnqueueItem()

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
void cQueue< ItemType, Funcs >::EnqueueItem ( ItemType  a_Item)
inline

Enqueues an item to the queue, may block if other threads are accessing the queue.

Definition at line 57 of file Queue.h.

◆ EnqueueItemIfNotPresent()

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
void cQueue< ItemType, Funcs >::EnqueueItemIfNotPresent ( ItemType  a_Item)
inline

Enqueues an item in the queue if not already present (as determined by operator ==).

Blocks other threads from accessing the queue.

Definition at line 66 of file Queue.h.

◆ Remove()

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
bool cQueue< ItemType, Funcs >::Remove ( ItemType  a_Item)
inline

Removes the item from the queue.

If there are multiple such items, only the first one is removed. Returns true if the item has been removed, false if no such item found.

Definition at line 150 of file Queue.h.

◆ RemoveIf()

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
template<class Predicate >
void cQueue< ItemType, Funcs >::RemoveIf ( Predicate  a_Predicate)
inline

Removes all items for which the predicate returns true.

Definition at line 168 of file Queue.h.

◆ Size()

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
size_t cQueue< ItemType, Funcs >::Size ( void  )
inline

Returns the size at time of being called.

Do not use to determine whether to call DequeueItem(), use TryDequeueItem() instead

Definition at line 141 of file Queue.h.

◆ TryDequeueItem()

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
bool cQueue< ItemType, Funcs >::TryDequeueItem ( ItemType &  item)
inline

Dequeues an item from the queue if any are present.

Returns true if successful. Value of item is undefined if dequeuing was unsuccessful.

Definition at line 85 of file Queue.h.

Member Data Documentation

◆ m_Contents

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
QueueType cQueue< ItemType, Funcs >::m_Contents
private

The contents of the queue.

Definition at line 190 of file Queue.h.

◆ m_CS

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
cCriticalSection cQueue< ItemType, Funcs >::m_CS
private

Mutex that protects access to the queue contents.

Definition at line 193 of file Queue.h.

◆ m_evtAdded

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
cEvent cQueue< ItemType, Funcs >::m_evtAdded
private

Event that is signalled when an item is added.

Definition at line 196 of file Queue.h.

◆ m_evtRemoved

template<class ItemType , class Funcs = cQueueFuncs<ItemType>>
cEvent cQueue< ItemType, Funcs >::m_evtRemoved
private

Event that is signalled when an item is removed (both dequeued or erased)

Definition at line 199 of file Queue.h.


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