A buffer class that holds a known capacity of fixed sized objects defined during creation.
More...
#include <thread.h>
|
| FixedBuffer (const FixedBuffer &fb) |
| Create a copy of an existing fixed size buffer and duplicate it's contents.
|
|
| FixedBuffer (size_t capacity, size_t objsize) |
| Create a buffer of known capacity for objects of a specified size.
|
|
bool | isValid (void) |
| New virtual to test if buffer is a valid object.
|
|
FixedBuffer & | operator= (const FixedBuffer &fb) |
|
virtual | ~FixedBuffer () |
| Destroy the fixed buffer and free the memory used to store objects.
|
|
| Buffer (size_t capacity) |
| Create a buffer object of known capacity.
|
|
size_t | getSize (void) const |
| Return the capacity of the buffer as specified at creation.
|
|
size_t | getUsed (void) const |
| Return the current capacity in use for the buffer.
|
|
size_t | peek (void *buf) |
| Peek at the current content (first object) in the buffer.
|
|
size_t | post (void *buf, timeout_t timeout=0) |
| Post an object into the buffer and enable a waiting thread to receive it.
|
|
size_t | wait (void *buf, timeout_t timeout=0) |
| Let one or more threads wait for an object to become available in the buffer.
|
|
virtual | ~Buffer () |
| In derived functions, may be used to free the actual memory used to hold buffered data.
|
|
|
size_t | onPeek (void *buf) |
| Return the first object in the buffer.
|
|
size_t | onPost (void *buf) |
| Post an object of the appropriate size into the buffer.
|
|
size_t | onWait (void *buf) |
| Wait for and return a fixed object in the buffer.
|
|
|
static const size_t | timeout |
| value to return when a timed operation returned with a timeout.
|
|
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 buffer class that holds a known capacity of fixed sized objects defined during creation.
- Author
- David Sugar dyfet.nosp@m.@ost.nosp@m.el.co.nosp@m.m
producer/consumer buffer for fixed size objects.
Definition at line 814 of file thread.h.
◆ FixedBuffer() [1/2]
ost::FixedBuffer::FixedBuffer |
( |
size_t | capacity, |
|
|
size_t | objsize ) |
Create a buffer of known capacity for objects of a specified size.
- Parameters
-
capacity | of the buffer. |
objsize | for each object held in the buffer. |
◆ FixedBuffer() [2/2]
ost::FixedBuffer::FixedBuffer |
( |
const FixedBuffer & | fb | ) |
|
Create a copy of an existing fixed size buffer and duplicate it's contents.
- Parameters
-
◆ isValid()
bool ost::FixedBuffer::isValid |
( |
void | | ) |
|
|
virtual |
New virtual to test if buffer is a valid object.
- Returns
- true if object is valid.
Reimplemented from ost::Buffer.
◆ onPeek()
size_t ost::FixedBuffer::onPeek |
( |
void * | buf | ) |
|
|
protectedvirtual |
Return the first object in the buffer.
- Returns
- predefined size of this buffers objects.
- Parameters
-
buf | pointer to copy contents of head of buffer to. |
Implements ost::Buffer.
◆ onPost()
size_t ost::FixedBuffer::onPost |
( |
void * | buf | ) |
|
|
protectedvirtual |
Post an object of the appropriate size into the buffer.
- Returns
- predefined size of this buffers objects.
- Parameters
-
buf | pointer to data to copy into the buffer. |
Implements ost::Buffer.
◆ onWait()
size_t ost::FixedBuffer::onWait |
( |
void * | buf | ) |
|
|
protectedvirtual |
Wait for and return a fixed object in the buffer.
- Returns
- predefined size of this buffers objects.
- Parameters
-
buf | pointer to hold object returned from the buffer. |
Implements ost::Buffer.
The documentation for this class was generated from the following file:
- /builddir/build/BUILD/ucommon-7.0.0-build/ucommon-7.0.0/inc/commoncpp/thread.h