A thread-safe buffer for serializing and streaming class data. More...
#include <containers.h>

Public Member Functions | |
| unsigned | count (void) |
| Get the number of objects in the buffer currently. | |
| operator bool () | |
| Test if there is data waiting in the buffer. | |
| bool | operator! () |
| Test if the buffer is empty. | |
| unsigned | size (void) |
| Get the size of the buffer. | |
Protected Member Functions | |
| Buffer (size_t typesize, size_t count) | |
| Create a buffer to hold a series of objects. | |
| bool | copy (void *data, timeout_t timeout) |
| Copy the next object from the buffer. | |
| void | copy (void *data) |
| Copy the next object from the buffer. | |
| void * | get (void) |
| Get the next object from the buffer. | |
| void * | get (timeout_t timeout) |
| Get the next object from the buffer. | |
| virtual void * | invalid (void) const |
| void * | peek (unsigned item) |
| Peek at pending data in buffer. | |
| bool | put (void *data, timeout_t timeout) |
| Put (copy) an object into the buffer. | |
| void | put (void *data) |
| Put (copy) an object into the buffer. | |
| void | release (void) |
| Release must be called when we get an object from the buffer. | |
| virtual | ~Buffer () |
| Deallocate buffer and unblock any waiting threads. | |
Related Functions | |
(Note that these are not member functions.) | |
| size_t | get (Buffer &b, void *o, timeout_t t=0) |
| size_t | peek (Buffer &b, void *o) |
| size_t | put (Buffer &b, void *o, timeout_t t=0) |
A thread-safe buffer for serializing and streaming class data.
While the queue and stack operate by managing lists of reference pointers to objects of various mixed kind, the buffer holds physical copies of objects that being passed through it, and all must be the same size. For this reason the buffer is normally used through the bufferof<type> template rather than stand-alone. The buffer is accessed in fifo order.
Definition at line 96 of file containers.h.
| Buffer::Buffer | ( | size_t | typesize, | |
| size_t | count | |||
| ) | [protected] |
Create a buffer to hold a series of objects.
| size | of each object in buffer. | |
| count | of objects in the buffer. |
| bool Buffer::copy | ( | void * | data, | |
| timeout_t | timeout | |||
| ) | [protected] |
| void Buffer::copy | ( | void * | data | ) | [protected] |
| unsigned Buffer::count | ( | void | ) |
Get the number of objects in the buffer currently.
| void* Buffer::get | ( | void | ) | [protected] |
Get the next object from the buffer.
This blocks until an object becomes available.
Reimplemented in bufferof< T >.
| void* Buffer::get | ( | timeout_t | timeout | ) | [protected] |
Get the next object from the buffer.
| timeout | to wait when buffer is empty in milliseconds. |
Reimplemented in bufferof< T >.
| Buffer::operator bool | ( | ) |
Test if there is data waiting in the buffer.
| bool Buffer::operator! | ( | ) |
Test if the buffer is empty.
| void* Buffer::peek | ( | unsigned | item | ) | [protected] |
| bool Buffer::put | ( | void * | data, | |
| timeout_t | timeout | |||
| ) | [protected] |
Put (copy) an object into the buffer.
| data | to copy into the buffer. | |
| timeout | to wait if buffer is full. |
| void Buffer::put | ( | void * | data | ) | [protected] |
Put (copy) an object into the buffer.
This blocks while the buffer is full.
| data | to copy into the buffer. |
| void Buffer::release | ( | void | ) | [protected] |
| unsigned Buffer::size | ( | void | ) |
Get the size of the buffer.
| size_t peek | ( | Buffer & | b, | |
| void * | o | |||
| ) | [related] |
1.6.1