Image Component Library (ICL)
|
This is used for concurrent writing and reading of Buffers. More...
#include <OpenNIUtils.h>
Public Member Functions | |
ReadWriteBuffer (ReadWriteBufferHandler< T > *buffer_handler) | |
Constructor creates and initializes resources. | |
~ReadWriteBuffer () | |
Destructor frees allocated memory. | |
T * | getNextReadBuffer () |
returns a pointer to the most recent actualized buffer. | |
T * | getNextReadBuffer (bool omit_double_frames=false, int omit_max_wait_millis=1000, int omit_sleep_micros=1000) |
returns pointer to most recent buffer. | |
T * | getNextWriteBuffer () |
returns a pointer to the next write Buffer. | |
void | setReset () |
mark buffers to be reset on next write-access. | |
void | switchHandler (ReadWriteBufferHandler< T > *new_handler) |
switches the handler | |
bool | newAvailable () |
tells whether a new ConvBuffers is available | |
Private Attributes | |
ReadWriteBufferHandler< T > * | m_BufferHandler |
the handler used to create new buffers | |
T * | m_Buffers [3] |
current objects which alternately are read and written. | |
bool | m_ResetBuffers [3] |
a bool for every buffer telling whether it needs a reset | |
utils::Mutex | m_Mutex |
the mutex is used for concurrent reading and writing. | |
int | m_Write |
the object currently written to. | |
int | m_Next |
the write object currently not written to. | |
int | m_Read |
the object currently read from. | |
bool | m_Avail |
tells whether an actualized object was written. |
This is used for concurrent writing and reading of Buffers.
This class holds three pointers to T of which one is the currently read and the other two are alternately written to.
icl::io::icl_openni::ReadWriteBuffer< T >::ReadWriteBuffer | ( | ReadWriteBufferHandler< T > * | buffer_handler | ) | [inline] |
Constructor creates and initializes resources.
icl::io::icl_openni::ReadWriteBuffer< T >::~ReadWriteBuffer | ( | ) | [inline] |
Destructor frees allocated memory.
T* icl::io::icl_openni::ReadWriteBuffer< T >::getNextReadBuffer | ( | ) | [inline] |
returns a pointer to the most recent actualized buffer.
Buffer will then be marked and not overwritten till the next call to getNextReadBuffer()
T* icl::io::icl_openni::ReadWriteBuffer< T >::getNextReadBuffer | ( | bool | omit_double_frames = false , |
int | omit_max_wait_millis = 1000 , |
||
int | omit_sleep_micros = 1000 |
||
) | [inline] |
returns pointer to most recent buffer.
if omit_double_frames is true, this function will call sleep for omit_sleep_millis and retry until a new buffer is available or omit_max_wait_millis is reached. when no new buffer could be returned NULL will be returned.
omit_double_frames | whether double frames should be omitted default value is false. |
omit_max_wait_millis | how long to wait for a new image before returning null. |
omit_sleep_micros | how long to sleep between checking for new buffer (in microseconds). will return null when no new ReadBuffer available. |
T* icl::io::icl_openni::ReadWriteBuffer< T >::getNextWriteBuffer | ( | ) | [inline] |
returns a pointer to the next write Buffer.
sets the returned Buffer as current writeable and marks the old writeable as new.
bool icl::io::icl_openni::ReadWriteBuffer< T >::newAvailable | ( | ) | [inline] |
tells whether a new ConvBuffers is available
void icl::io::icl_openni::ReadWriteBuffer< T >::setReset | ( | ) | [inline] |
mark buffers to be reset on next write-access.
void icl::io::icl_openni::ReadWriteBuffer< T >::switchHandler | ( | ReadWriteBufferHandler< T > * | new_handler | ) | [inline] |
switches the handler
bool icl::io::icl_openni::ReadWriteBuffer< T >::m_Avail [private] |
tells whether an actualized object was written.
ReadWriteBufferHandler<T>* icl::io::icl_openni::ReadWriteBuffer< T >::m_BufferHandler [private] |
the handler used to create new buffers
T* icl::io::icl_openni::ReadWriteBuffer< T >::m_Buffers[3] [private] |
current objects which alternately are read and written.
utils::Mutex icl::io::icl_openni::ReadWriteBuffer< T >::m_Mutex [private] |
the mutex is used for concurrent reading and writing.
int icl::io::icl_openni::ReadWriteBuffer< T >::m_Next [private] |
the write object currently not written to.
int icl::io::icl_openni::ReadWriteBuffer< T >::m_Read [private] |
the object currently read from.
bool icl::io::icl_openni::ReadWriteBuffer< T >::m_ResetBuffers[3] [private] |
a bool for every buffer telling whether it needs a reset
int icl::io::icl_openni::ReadWriteBuffer< T >::m_Write [private] |
the object currently written to.