XII Release 0.1.0
Loading...
Searching...
No Matches
xiiMessageQueueBase< MetaDataType > Class Template Reference

Copyright (c) Theophilus Eriata. All Rights Reserved. More...

#include <MessageQueue.h>

Inheritance diagram for xiiMessageQueueBase< MetaDataType >:
[legend]

Classes

struct  Entry

Public Member Functions

Entry & operator[] (xiiUInt32 uiIndex)
 Returns the element at the given index. Not thread safe.
const Entry & operator[] (xiiUInt32 uiIndex) const
 Returns the element at the given index. Not thread safe.
xiiUInt32 GetCount () const
 Returns the number of active elements in the queue.
bool IsEmpty () const
 Returns true, if the queue does not contain any elements.
void Clear ()
 Destructs all elements and sets the count to zero. Does not deallocate any data.
void Reserve (xiiUInt32 uiCount)
 Expands the queue so it can at least store the given capacity.
void Compact ()
 Tries to compact the array to avoid wasting memory.The resulting capacity is at least 'GetCount' (no elements get removed).
void Enqueue (xiiMessage *pMessage, const MetaDataType &metaData)
 Enqueues the given message and meta-data. This method is thread safe.
bool TryDequeue (xiiMessage *&out_pMessage, MetaDataType &out_metaData)
 Dequeues the first element if the queue is not empty and returns true. Returns false if the queue is empty. This method is thread safe.
bool TryPeek (xiiMessage *&out_pMessage, MetaDataType &out_metaData)
 Gives the first element if the queue is not empty and returns true. Returns false if the queue is empty. This method is thread safe.
Entry & Peek ()
 Returns the first element in the queue. Not thread safe.
void Dequeue ()
 Removes the first element from the queue. Not thread safe.
template<typename Comparer>
void Sort (const Comparer &comparer)
 Sort with explicit comparer. Not thread safe.
void Lock ()
 Acquires an exclusive lock on the queue. Do not use this method directly but use xiiLock instead.
void Unlock ()
 Releases a lock that has been previously acquired. Do not use this method directly but use xiiLock instead.
template<typename Comparer>
XII_ALWAYS_INLINE void Sort (const Comparer &comparer)

Protected Member Functions

 xiiMessageQueueBase (xiiAllocator *pAllocator)
 No memory is allocated during construction.
 xiiMessageQueueBase (const xiiMessageQueueBase &rhs, xiiAllocator *pAllocator)
 No memory is allocated during construction.
 ~xiiMessageQueueBase ()
 Destructor.
void operator= (const xiiMessageQueueBase &rhs)
 Assignment operator.

Detailed Description

template<typename MetaDataType>
class xiiMessageQueueBase< MetaDataType >

Copyright (c) Theophilus Eriata. All Rights Reserved.

Implementation of a message queue on top of a deque.

Enqueue and TryDequeue/TryPeek methods are thread safe all the others are not. To ensure thread safety for all methods the queue can be locked using xiiLock like a mutex. Every entry consists of a pointer to a message and some meta data. Lifetime of the enqueued messages needs to be managed by the user.

See also
xiiMessage

Constructor & Destructor Documentation

◆ xiiMessageQueueBase()

template<typename MetaDataType>
xiiMessageQueueBase< MetaDataType >::xiiMessageQueueBase ( xiiAllocator * pAllocator)
protected

No memory is allocated during construction.

Copyright (c) Theophilus Eriata. All Rights Reserved.


The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Communication/MessageQueue.h
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Communication/Implementation/MessageQueue_inl.h