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 Reference A thread-safe data pipe with buffer semantics. More...
Inherits Monitor< IceUtil::Mutex >.
Detailed Descriptiontemplate<class Type>
|
gbxiceutilacfr::Buffer< Type >::Buffer | ( | int | depth = -1 , |
BufferType | type = BufferTypeQueue |
||
) |
Buffer depth, i.e. the maximum number of objects this buffer can hold:
void gbxiceutilacfr::Buffer< Type >::configure | ( | int | depth, |
BufferType | type = BufferTypeCircular |
||
) |
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.
void gbxiceutilacfr::Buffer< Type >::get | ( | Type & | obj | ) | const |
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 >::get | ( | Type & | obj, |
unsigned int | n | ||
) | const |
Non-popping and non-blocking random-access read. Returns n-th element from the buffer. Indexing starts at 0.
void gbxiceutilacfr::Buffer< Type >::getAndPop | ( | Type & | obj | ) |
int gbxiceutilacfr::Buffer< Type >::getAndPopWithTimeout | ( | Type & | obj, |
int | timeoutMs = -1 |
||
) |
Same as getWithTimeout but calls pop afterwards.
int gbxiceutilacfr::Buffer< Type >::getWithTimeout | ( | Type & | obj, |
int | timeoutMs = -1 |
||
) |
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.
void gbxiceutilacfr::Buffer< Type >::pop | ( | ) |
Pops the front element off and discards it (usually after calling get() ). If the buffer is empty this command is quietly ignored.
void gbxiceutilacfr::Buffer< Type >::push | ( | const Type & | obj | ) |
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.