ucommon
|
A templated typed class for buffering of objects. More...
#include <containers.h>
Public Member Functions | |
const T & | at (unsigned item) |
Examine past item in the buffer. More... | |
bufferof (unsigned capacity) | |
Create a buffer to hold a series of typed objects. More... | |
void | copy (T *object) |
Copy the next typed object from the buffer. More... | |
T * | get (void) |
Get the next typed object from the buffer. More... | |
T * | get (timeout_t timeout) |
Get the next typed object from the buffer. More... | |
bool | get (T *object, timeout_t timeout) |
Copy the next typed object from the buffer. More... | |
T * | operator() (unsigned offset=0) |
T & | operator[] (unsigned item) |
Examine past item in the buffer. More... | |
void | put (T *object) |
Put (copy) a typed object into the buffer. More... | |
bool | put (T *object, timeout_t timeout) |
Put (copy) an object into the buffer. More... | |
![]() | |
unsigned | count (void) const |
Get the number of objects in the buffer currently. More... | |
operator bool () const | |
Test if there is data waiting in the buffer. More... | |
bool | operator! () const |
Test if the buffer is empty. More... | |
unsigned | size (void) const |
Get the size of the buffer. More... | |
Additional Inherited Members | |
![]() | |
Buffer (size_t typesize, size_t count) | |
Create a buffer to hold a series of objects. More... | |
void | copy (void *data) |
Copy the next object from the buffer. More... | |
bool | copy (void *data, timeout_t timeout) |
Copy the next object from the buffer. More... | |
void * | get (timeout_t timeout) |
Get the next object from the buffer. More... | |
void * | get (void) |
Get the next object from the buffer. More... | |
virtual void * | invalid (void) const |
void * | peek (unsigned item) |
Peek at pending data in buffer. More... | |
void | put (void *data) |
Put (copy) an object into the buffer. More... | |
bool | put (void *data, timeout_t timeout) |
Put (copy) an object into the buffer. More... | |
void | release (void) |
Release must be called when we get an object from the buffer. More... | |
virtual | ~Buffer () |
Deallocate buffer and unblock any waiting threads. | |
![]() | |
void | broadcast (void) |
Signal the conditional to release all waiting threads. | |
Conditional () | |
Initialize and construct conditional. | |
void | lock (void) |
Lock the conditional's supporting mutex. | |
void | signal (void) |
Signal the conditional to release one waiting thread. | |
void | unlock (void) |
Unlock the conditional's supporting mutex. | |
bool | wait (timeout_t timeout) |
Conditional wait for signal on millisecond timeout. More... | |
bool | wait (struct timespec *timeout) |
Conditional wait for signal on timespec timeout. More... | |
void | wait (void) |
Wait (block) until signalled. | |
~Conditional () | |
Destroy conditional, release any blocked threads. | |
![]() | |
static pthread_condattr_t * | initializer (void) |
Support function for getting conditional attributes for realtime scheduling. More... | |
static void | set (struct timespec *hires, timeout_t timeout) |
Convert a millisecond timeout into use for high resolution conditional timers. More... | |
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 434 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 441 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 500 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 482 of file containers.h.
|
inline |
Get the next typed object from the buffer.
This blocks until an object becomes available.
Definition at line 449 of file containers.h.
|
inline |
Get the next typed object from the buffer.
timeout | to wait when buffer is empty in milliseconds. |
Definition at line 457 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 491 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 509 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 465 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 474 of file containers.h.