![]() |
CPPMyth
Library to interoperate with MythTV server
|

Data Structures | |
| struct | Chunk |
| total size of unread data in the buffer More... | |
Public Member Functions | |
| RingBuffer (int capacity) | |
| int | capacity () const |
| int | bytesAvailable () |
| unsigned | bytesUnread () const |
| bool | full () const |
| void | clear () |
| int | write (const char *data, int len) |
| RingBufferPacket * | newPacket (int len) |
| void | writePacket (RingBufferPacket *packet) |
| RingBufferPacket * | read () |
| void | freePacket (RingBufferPacket *p) |
Private Member Functions | |
| RingBuffer (const RingBuffer &other) | |
| RingBuffer & | operator= (const RingBuffer &other) |
| void | init () |
| chunk to write | |
| RingBufferPacket * | needPacket (int size) |
Private Attributes | |
| OS::Mutex * | m_ringlock |
| OS::Mutex * | m_poollock |
| const int | m_capacity |
| unsigned | m_count |
| buffer size | |
| unsigned | m_unread |
| total count of processed chunk | |
| std::vector< Chunk * > | m_buffer |
| Chunk * | m_read |
| buffer of chunk | |
| Chunk * | m_write |
| chunk to read | |
| std::list< RingBufferPacket * > | m_pool |
Definition at line 55 of file ringbuffer.h.
| RingBuffer::RingBuffer | ( | int | capacity | ) |
Definition at line 42 of file ringbuffer.cpp.
|
virtual |
Definition at line 58 of file ringbuffer.cpp.
| int RingBuffer::bytesAvailable | ( | ) |
It returns the size in bytes of the next chunk to read.
Definition at line 96 of file ringbuffer.cpp.
| unsigned RingBuffer::bytesUnread | ( | ) | const |
It returns the total size in bytes of all chunks remaining to be read.
Definition at line 107 of file ringbuffer.cpp.
References m_unread.
| int RingBuffer::capacity | ( | ) | const |
Buffer capacity is defined in CTOR and it cannot be changed. It is the number of chunk chained in the ring of the buffer. Each chunk can hold different size of payload.
Definition at line 91 of file ringbuffer.cpp.
| void RingBuffer::clear | ( | ) |
Clear all unread chunks.
Definition at line 119 of file ringbuffer.cpp.
References freePacket(), m_count, m_read, m_unread, and m_write.
| void RingBuffer::freePacket | ( | RingBufferPacket * | p | ) |
Recycle the payload for reuse.
| p | payload |
Definition at line 204 of file ringbuffer.cpp.
Referenced by clear(), write(), and writePacket().

| bool RingBuffer::full | ( | ) | const |
When the buffer is full, writing new data will overwrite the next available chunk for reading.
Definition at line 113 of file ringbuffer.cpp.
|
private |
|
private |
Definition at line 211 of file ringbuffer.cpp.
| RingBufferPacket * RingBuffer::newPacket | ( | int | len | ) |
It returns a pointer to payload to be written. Its capacity is at least equal to requested size (len). After copying data and assigning the size, the payload can be written to the buffer. An unused payload MUST BE freed by caller using freePacket(RingBufferPacket*).
| len | requested size in bytes |
Definition at line 159 of file ringbuffer.cpp.
| RingBufferPacket * RingBuffer::read | ( | ) |
Read the next chunk available. Returned pointer MUST BE freed by caller.
Definition at line 185 of file ringbuffer.cpp.
| int RingBuffer::write | ( | const char * | data, |
| int | len ) |
Write a chunk in the buffer.
| data | pointer to data |
| len | length of data |
Definition at line 134 of file ringbuffer.cpp.
References freePacket(), m_count, m_unread, and m_write.
| void RingBuffer::writePacket | ( | RingBufferPacket * | packet | ) |
Write a chunk in the buffer.
| packet | payload |
Definition at line 166 of file ringbuffer.cpp.
References freePacket(), m_count, m_unread, and m_write.
|
private |
Definition at line 152 of file ringbuffer.h.
|
private |
Definition at line 140 of file ringbuffer.h.
|
private |
buffer size
Definition at line 141 of file ringbuffer.h.
Referenced by clear(), write(), and writePacket().
|
private |
Definition at line 158 of file ringbuffer.h.
|
mutableprivate |
Definition at line 139 of file ringbuffer.h.
|
private |
buffer of chunk
Definition at line 153 of file ringbuffer.h.
Referenced by bytesAvailable(), clear(), full(), init(), and read().
|
mutableprivate |
Definition at line 138 of file ringbuffer.h.
|
private |
total count of processed chunk
Definition at line 142 of file ringbuffer.h.
Referenced by bytesAvailable(), bytesUnread(), clear(), full(), read(), write(), and writePacket().
|
private |
chunk to read
Definition at line 154 of file ringbuffer.h.
Referenced by clear(), full(), init(), write(), and writePacket().