![]() |
VR-Forces Developer's Guide
|
A locked buffered queue which allows multiple writers and a single reader. Internally the queue is stored as a double buffered vector. Ideally the vector will not shrink in size so frequent calls getForReading is advised.

Public Member Functions | |
| DtLockedBufferedQueue () | |
| ~DtLockedBufferedQueue () | |
| unsigned int | push (T value) |
| unsigned int | push (std::vector< T > &valueVector) |
| void | getForReading (std::vector< T > *&output) |
| void | deleteAllPointers () |
| void | nullAllPointers () |
| void | clearBuffers () |
Protected Member Functions | |
| void | swapBuffers () |
Protected Attributes | |
| std::vector< T > | myFirstBuffer |
| std::vector< T > | mySecondBuffer |
| std::vector< T > * | myCurrentBuffer |
| DtMutex | myBufferMutex |
| makVrv::DtLockedBufferedQueue< T >::DtLockedBufferedQueue | ( | ) |
| makVrv::DtLockedBufferedQueue< T >::~DtLockedBufferedQueue | ( | ) |
DTOR If the type T is a pointer memory must be explicitly deleting by iterating throug both vectors call getForReading twice.
| unsigned int makVrv::DtLockedBufferedQueue< T >::push | ( | T | value | ) |
Add a value to to the buffer. This function is thread safe and reentrant. The return value is the current size of the buffer. This is useful when throttling writing speed due to insufficient reads.
| unsigned int makVrv::DtLockedBufferedQueue< T >::push | ( | std::vector< T > & | valueVector | ) |
Add several values to to the buffer. This function is thread safe and reentrant. The return value is the current size of the buffer. This is useful when throttling writing speed due to insufficient reads.
| void makVrv::DtLockedBufferedQueue< T >::getForReading | ( | std::vector< T > *& | output | ) |
Get a vector for reading. This function should only be called by the reader thread. The pointer reference is written to, and can be initially null. The pointer is guaranteed to be valid and not NULL after a call to getForReading. The pointer is only valid until the next call to getForReading. There is no need to clear the buffer when reading is done. The contents of the output will not change until the next call to getForReading. All iterators are invalidated with the next call to getForReading.
| void makVrv::DtLockedBufferedQueue< T >::deleteAllPointers | ( | ) |
Helper function for deleting all member pointers in both buffers. This function is not valid if T is not a pointer type, of the pointers are not allocated using 'new' or if they used new[].
| void makVrv::DtLockedBufferedQueue< T >::nullAllPointers | ( | ) |
Helper function for setting all member pointers to null in both buffers (for reference pointers, osg::ref_ptr). This function is not valid if T is not a pointer type, of the pointers are not allocated using 'new' or if they used new[].
| void makVrv::DtLockedBufferedQueue< T >::clearBuffers | ( | ) |
Helper function to clear all the buffers, if the buffers contain pointers call deleteAllPointers() first.
|
protected |
Internal function for swapping buffers and clearing the write buffer.
|
protected |
|
protected |
|
protected |
|
protected |