VR-Engage  2.2
Loading...
Searching...
No Matches
makRadarFx::DtLocklessQueue< T > Class Template Reference

Detailed Description

template<class T>
class makRadarFx::DtLocklessQueue< T >
Template Parameters
TType of elements stored in the queue

This template class provides a thread-safe queue designed for transferring data between a single producer thread and a single consumer thread without requiring locks. The implementation may block if the queue fills up, providing backpressure to prevent overflow. This queue is optimized for performance in inter-thread communication scenarios.

#include <locklessQueue.h>

Inheritance diagram for makRadarFx::DtLocklessQueue< T >:
[legend]

Public Member Functions

 DtLocklessQueue (int size)
 
 ~DtLocklessQueue ()
 
void push (T newElement)
 
pop ()
 
bool okToPush ()
 
int count ()
 

Protected Attributes

std::vector< T > myElements
 
int myReadHead
 
int myWriteHead
 

Private Member Functions

 DtLocklessQueue ()
 
 DtLocklessQueue (const DtLocklessQueue &orig)
 
DtLocklessQueueoperator= (const DtLocklessQueue &rhs)
 

Constructor & Destructor Documentation

◆ DtLocklessQueue() [1/3]

template<class T>
makRadarFx::DtLocklessQueue< T >::DtLocklessQueue ( int size)

Constructor with specified queue capacity.

Parameters
sizeMaximum number of elements that can be stored in the queue

Creates a new lockless queue with the specified capacity

Referenced by DtLocklessQueue(), and operator=().

◆ ~DtLocklessQueue()

template<class T>
makRadarFx::DtLocklessQueue< T >::~DtLocklessQueue ( )

Destructor.

Cleans up and releases all queue resources

◆ DtLocklessQueue() [2/3]

template<class T>
makRadarFx::DtLocklessQueue< T >::DtLocklessQueue ( )
private

Default constructor.

Intentionally unimplemented to prevent usage

◆ DtLocklessQueue() [3/3]

template<class T>
makRadarFx::DtLocklessQueue< T >::DtLocklessQueue ( const DtLocklessQueue< T > & orig)
private

Copy constructor.

Parameters
origQueue to copy from

Intentionally unimplemented to prevent copying

References DtLocklessQueue().

Member Function Documentation

◆ push()

template<class T>
void makRadarFx::DtLocklessQueue< T >::push ( T newElement)

Adds an element to the queue.

Parameters
newElementElement to add to the queue

Adds an element to the queue. If the queue is full, this method will block until space becomes available. This method is safe to call from a single producer thread.

◆ pop()

template<class T>
T makRadarFx::DtLocklessQueue< T >::pop ( )

Removes and returns an element from the queue.

Returns
The next element from the queue

Removes and returns the next element from the queue. If the queue is empty, this method will block until data becomes available. This method is safe to call from a single consumer thread.

◆ okToPush()

template<class T>
bool makRadarFx::DtLocklessQueue< T >::okToPush ( )

Checks if there is room to add an element without blocking.

Returns
True if push() can be called without blocking, false otherwise

This method checks if the queue has space available for adding an element. If this returns false, a call to push() will block until space is available.

◆ count()

template<class T>
int makRadarFx::DtLocklessQueue< T >::count ( )

Gets the current number of elements in the queue.

Returns
Number of elements currently in the queue

Returns the number of elements currently stored in the queue. This is thread-safe but may not be atomically consistent with other operations.

◆ operator=()

template<class T>
DtLocklessQueue & makRadarFx::DtLocklessQueue< T >::operator= ( const DtLocklessQueue< T > & rhs)
private

Assignment operator.

Parameters
rhsQueue to assign from
Returns
Reference to this queue

Intentionally unimplemented to prevent assignment

References DtLocklessQueue().

Member Data Documentation

◆ myElements

template<class T>
std::vector<T> makRadarFx::DtLocklessQueue< T >::myElements
protected

Storage for queue elements.

◆ myReadHead

template<class T>
int makRadarFx::DtLocklessQueue< T >::myReadHead
protected

Index of the next element to read Value of -1 indicates the queue is empty.

◆ myWriteHead

template<class T>
int makRadarFx::DtLocklessQueue< T >::myWriteHead
protected

Index where the next element will be written.


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