|
Open Model Railroad Network (OpenMRN)
|
Implements a smart buffer specifically designed for character device drivers. More...
#include <DeviceBuffer.hxx>
Public Types | |
| typedef T | member_type |
Public Member Functions | |
| void | destroy () |
| Destroy an existing DeviceBuffer instance. | |
| size_t | put (const T *buf, size_t items) |
| Insert a number of items to the buffer. | |
| size_t | get (T *buf, size_t items) |
| remove a number of items from the buffer. | |
| size_t | data_read_pointer (T **buf) |
| Get a reference to the current location in the buffer for read. | |
| size_t | data_write_pointer (T **buf) |
| Get a reference to the current location in the buffer for write. | |
Public Member Functions inherited from DeviceBufferBase | |
| void | signal_condition () |
| Signal the wakeup condition. | |
| void | signal_condition_from_isr () |
| Signal the wakeup condition from an ISR context. | |
| void | flush () |
| flush all the data out of the buffer and reset the buffer. | |
| size_t | pending () |
| Return the number of items in the queue. | |
| size_t | space () |
| Return the number of items for which space is available. | |
| void | select_insert () |
| Add client to list of clients needing woken. | |
| size_t | consume (size_t items) |
| Remove a number of items from the buffer by advancing the readIndex. | |
| size_t | advance (size_t items) |
| Add a number of items to the buffer by advancing the writeIndex. | |
Static Public Member Functions | |
| static DeviceBuffer * | create (size_t size, size_t level=0) |
| Create a DeviceBuffer instance. | |
| static constexpr unsigned | member_size () |
Private Member Functions | |
| DeviceBuffer (size_t size, size_t level) | |
| Constructor. | |
| ~DeviceBuffer () | |
| Destructor. | |
| DISALLOW_COPY_AND_ASSIGN (DeviceBuffer) | |
Private Attributes | |
| T | data [] |
| buffer data | |
Additional Inherited Members | |
Protected Member Functions inherited from DeviceBufferBase | |
| DeviceBufferBase (size_t size, size_t level) | |
| Constructor. | |
| ~DeviceBufferBase () | |
| Destructor. | |
Protected Attributes inherited from DeviceBufferBase | |
| uint16_t | level |
| level of space required in buffer in order to wakeup, 0 if unused | |
| uint16_t | size |
| size in items of buffer | |
| uint16_t | count |
| total number of items in buffer | |
| uint16_t | readIndex |
| read index | |
| uint16_t | writeIndex |
| write index | |
Implements a smart buffer specifically designed for character device drivers.
Technically, the private metadata for the size and index counters should more properly be implemented as size_t types. The choice of uint16_t types is simply to save memory as 2^16 is normally a reasonable maximum size for this type of metadata.
Definition at line 215 of file DeviceBuffer.hxx.
| typedef T DeviceBuffer< T >::member_type |
Definition at line 236 of file DeviceBuffer.hxx.
|
inlineprivate |
Constructor.
| size | size in items for the buffer. |
| level | minimum amount of space required in buffer to restart transmitting, unused for receive. |
Definition at line 337 of file DeviceBuffer.hxx.
|
inlineprivate |
Destructor.
Definition at line 344 of file DeviceBuffer.hxx.
|
inlinestatic |
Create a DeviceBuffer instance.
| size | size in items for the DeviceBuffer |
| level | minimum amount of space required in buffer to restart transmitting, unused for receive. |
Definition at line 224 of file DeviceBuffer.hxx.
|
inline |
Get a reference to the current location in the buffer for read.
| buf | location to store resulting reference |
Definition at line 304 of file DeviceBuffer.hxx.
|
inline |
Get a reference to the current location in the buffer for write.
| buf | location to store resulting reference |
Definition at line 320 of file DeviceBuffer.hxx.
|
inline |
Destroy an existing DeviceBuffer instance.
Definition at line 248 of file DeviceBuffer.hxx.
|
inline |
remove a number of items from the buffer.
| buf | reference to the data removed |
| items | total number of items to remove |
Definition at line 281 of file DeviceBuffer.hxx.
|
inlinestaticconstexpr |
Definition at line 239 of file DeviceBuffer.hxx.
|
inline |
Insert a number of items to the buffer.
| buf | reference to the first item to insert |
| items | total number of items to insert |
Definition at line 258 of file DeviceBuffer.hxx.
|
private |
buffer data
Definition at line 351 of file DeviceBuffer.hxx.