|
VR-Engage
2.2
|
| T | Type 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>
Public Member Functions | |
| DtLocklessQueue (int size) | |
| ~DtLocklessQueue () | |
| void | push (T newElement) |
| T | pop () |
| bool | okToPush () |
| int | count () |
Protected Attributes | |
| std::vector< T > | myElements |
| int | myReadHead |
| int | myWriteHead |
Private Member Functions | |
| DtLocklessQueue () | |
| DtLocklessQueue (const DtLocklessQueue &orig) | |
| DtLocklessQueue & | operator= (const DtLocklessQueue &rhs) |
| makRadarFx::DtLocklessQueue< T >::DtLocklessQueue | ( | int | size | ) |
Constructor with specified queue capacity.
| size | Maximum number of elements that can be stored in the queue |
Creates a new lockless queue with the specified capacity
Referenced by DtLocklessQueue(), and operator=().
| makRadarFx::DtLocklessQueue< T >::~DtLocklessQueue | ( | ) |
Destructor.
Cleans up and releases all queue resources
|
private |
Default constructor.
Intentionally unimplemented to prevent usage
|
private |
Copy constructor.
| orig | Queue to copy from |
Intentionally unimplemented to prevent copying
References DtLocklessQueue().
| void makRadarFx::DtLocklessQueue< T >::push | ( | T | newElement | ) |
Adds an element to the queue.
| newElement | Element 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.
| T makRadarFx::DtLocklessQueue< T >::pop | ( | ) |
Removes and returns an 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.
| bool makRadarFx::DtLocklessQueue< T >::okToPush | ( | ) |
| int makRadarFx::DtLocklessQueue< T >::count | ( | ) |
Gets the current number of elements 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.
|
private |
Assignment operator.
| rhs | Queue to assign from |
Intentionally unimplemented to prevent assignment
References DtLocklessQueue().
|
protected |
Storage for queue elements.
|
protected |
Index of the next element to read Value of -1 indicates the queue is empty.
|
protected |
Index where the next element will be written.