ucommon
|
A templated typed class for buffering of objects. More...
#include <containers.h>
Public Member Functions | |
bufferof (unsigned count) | |
Create a buffer to hold a series of typed objects. | |
void | copy (T *object) |
Copy the next typed object from the buffer. | |
T * | get (void) |
Get the next typed object from the buffer. | |
T * | get (timeout_t timeout) |
Get the next typed object from the buffer. | |
bool | get (T *object, timeout_t timeout) |
Copy the next typed object from the buffer. | |
T * | operator[] (unsigned item) |
Examine past item in the buffer. | |
T * | peek (unsigned item) |
Examine past item in the buffer. | |
void | put (T *object) |
Put (copy) a typed object into the buffer. | |
bool | put (T *object, timeout_t timeout) |
Put (copy) an object into the buffer. | |
![]() | |
Buffer (size_t size, size_t count) | |
Create a buffer to hold a series of objects. | |
void | copy (void *data) |
Copy the next object from the buffer. | |
bool | copy (void *data, timeout_t timeout) |
Copy the next object from the buffer. | |
unsigned | getCount (void) |
Get the number of objects in the buffer currently. | |
unsigned | getSize (void) |
Get the size of the buffer. | |
operator bool () | |
Test if there is data waiting in the buffer. | |
bool | operator! () |
Test if the buffer is empty. | |
void | put (void *data) |
Put (copy) an object into the buffer. | |
bool | put (void *data, timeout_t timeout) |
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. |
Additional Inherited Members | |
![]() | |
static void | gettimeout (timeout_t timeout, struct timespec *hires) |
Convert a millisecond timeout into use for high resolution conditional timers. | |
static pthread_condattr_t * | initializer (void) |
Support function for getting conditional attributes for realtime scheduling. |
A templated typed class for buffering of objects.
This operates as a fifo buffer of typed objects which are physically copied into the buffer. The objects that are buffered are accessed from allocated buffer space. As designed this may be used with multiple producer threads and one consumer thread. To use multiple consumers, one can copy the typed object from the buffer through the get pointer and then call release. The copied object can then be used safely. This is what the copy method is used for.
Definition at line 512 of file containers.h.
|
inline |
Create a buffer to hold a series of typed objects.
count | of typed objects in the buffer. |
Definition at line 519 of file containers.h.
|
inline |
Copy the next typed object from the buffer.
This blocks until an object becomes available.
object | pointer to copy typed object into. |
Definition at line 560 of file containers.h.
|
inline |
Get the next typed object from the buffer.
This blocks until an object becomes available.
Reimplemented from ucommon::Buffer.
Definition at line 527 of file containers.h.
|
inline |
Get the next typed object from the buffer.
timeout | to wait when buffer is empty in milliseconds. |
Reimplemented from ucommon::Buffer.
Definition at line 535 of file containers.h.
|
inline |
Copy the next typed object from the buffer.
object | pointer to copy typed object into. |
timeout | to wait when buffer is empty in milliseconds. |
Definition at line 569 of file containers.h.
|
inline |
Examine past item in the buffer.
This is a typecast of the peek operation.
item | in buffer. |
Definition at line 587 of file containers.h.
|
inline |
Examine past item in the buffer.
This is a typecast of the peek operation.
item | in buffer. |
Reimplemented from ucommon::Buffer.
Definition at line 578 of file containers.h.
|
inline |
Put (copy) a typed object into the buffer.
This blocks while the buffer is full.
object | to copy into the buffer. |
Definition at line 543 of file containers.h.
|
inline |
Put (copy) an object into the buffer.
object | to copy into the buffer. |
timeout | to wait if buffer is full. |
Definition at line 552 of file containers.h.