INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
gbxiceutilacfr::Buffer< Type > Class Template ReferenceA thread-safe data pipe with buffer semantics. More...
Detailed Descriptiontemplate<class Type>
A thread-safe data pipe with buffer semantics.
|
gbxiceutilacfr::Buffer< Type >::Buffer | ( | int | depth = -1 , |
|
BufferType | type = BufferTypeQueue | |||
) | [inline] |
Buffer depth, i.e. the maximum number of objects this buffer can hold:
References gbxiceutilacfr::Buffer< Type >::purge().
void gbxiceutilacfr::Buffer< Type >::configure | ( | int | depth, | |
BufferType | type = BufferTypeCircular | |||
) | [inline] |
Typically is called before the buffer is used, or if, for some reason, the configuration information was not available at the time when the constructor was called. Careful: all data currently in the buffer is lost, because purge() is calledfirst. NOTE: can do smarter by trancating queue only as much as needed.
References gbxiceutilacfr::Buffer< Type >::purge().
void gbxiceutilacfr::Buffer< Type >::get | ( | Type & | obj, | |
unsigned int | n | |||
) | const [inline] |
Non-popping and non-blocking random-access read. Returns n-th element from the buffer. Indexing starts at 0.
void gbxiceutilacfr::Buffer< Type >::get | ( | Type & | obj | ) | const [inline] |
Non-popping and non-blocking read from the front of the buffer.
Calls to get() on an empty buffer raises an gbxutilacfr::Exception exception. You can catch these and call getWithTimeout() which will block until new data arrives.
void gbxiceutilacfr::Buffer< Type >::getAndPop | ( | Type & | obj | ) | [inline] |
int gbxiceutilacfr::Buffer< Type >::getAndPopWithTimeout | ( | Type & | obj, | |
int | timeoutMs = -1 | |||
) | [inline] |
Same as getWithTimeout but calls pop afterwards.
References gbxiceutilacfr::Buffer< Type >::getWithTimeout(), and gbxiceutilacfr::Buffer< Type >::pop().
int gbxiceutilacfr::Buffer< Type >::getWithTimeout | ( | Type & | obj, | |
int | timeoutMs = -1 | |||
) | [inline] |
If there is an object in the buffer, sets the object and returns 0;
If the buffer is empty, getWithTimeout() blocks until a new object is pushed in and returns the new value. By default, there is an infinite timeout (negative value). Returns 0 if successful.
If timeout is set to a positive value and the wait times out, this function returns -1 and the object argument itself is not touched. In the rare event of spurious wakeup, the return value is 1.
Referenced by gbxiceutilacfr::Buffer< Type >::getAndPopWithTimeout().
void gbxiceutilacfr::Buffer< Type >::pop | ( | ) | [inline] |
Pops the front element off and discards it (usually after calling get() ). If the buffer is empty this command is quietly ignored.
Referenced by gbxiceutilacfr::Buffer< Type >::getAndPopWithTimeout().
void gbxiceutilacfr::Buffer< Type >::push | ( | const Type & | obj | ) | [inline] |
Adds an object to the end of the buffer. If there is no room left in a finite-depth circular buffer, the front element of the buffer is quietly deleted and the new data is added to the end. If there is no room left in a finite-depth queue buffer the new data is quietly ignored.
References gbxiceutilacfr::BufferTypeCircular.