![]() |
GM6000 Digital Heater Controller Build: 20 (Branch = develop)
SDX-1330
|
This template class implements a THREAD SAFE Ring Buffer AND it maintains/reports the number of elements stored in the ring buffer via a Model Point. More...
This template class implements a THREAD SAFE Ring Buffer AND it maintains/reports the number of elements stored in the ring buffer via a Model Point.
The size of the ring buffer is limited by number of bits in platform's 'unsigned' data type.
Template Args: ITEM:= Type of the data stored in the Ring Buffer
#include <RingBufferMP.h>
Public Member Functions | |
| RingBufferMP (unsigned maxElements, ITEM memoryForElements[], Cpl::Dm::Mp::Uint32 &mpElementCount) noexcept | |
| Constructor. | |
| bool | remove (ITEM &dst) noexcept |
| See Cpl::Container::RingBuffer. | |
| bool | remove (ITEM &dst, uint16_t &seqNum) noexcept |
| Extends remove() to expose/return the MP's sequence number on the update. | |
| bool | add (const ITEM &item) noexcept |
| See Cpl::Container::RingBuffer. | |
| bool | add (const ITEM &item, uint16_t &seqNum) noexcept |
| Extends add() to expose/return the MP's sequence number on the update. | |
| void | clearTheBuffer () noexcept |
| See Cpl::Container::RingBuffer. | |
| void | clearTheBuffer (uint16_t &seqNum) noexcept |
| Extends add() to expose/return the MP's sequence number on the update. | |
Public Member Functions inherited from Cpl::Container::RingBufferMT< ITEM > | |
| RingBufferMT (unsigned maxElements, ITEM memoryForElements[]) noexcept | |
| Constructor. | |
| bool | remove (ITEM &dst) noexcept |
| See Cpl::Container::RingBuffer. | |
| bool | add (const ITEM &item) noexcept |
| See Cpl::Container::RingBuffer. | |
| ITEM * | peekHead (void) const noexcept |
| See Cpl::Container::RingBuffer. | |
| ITEM * | peekTail (void) const noexcept |
| See Cpl::Container::RingBuffer. | |
| ITEM * | peekNextAddItems (unsigned &dstNumFlatElements) noexcept |
| This method returns a pointer to the next item to be added. | |
| void | addElements (unsigned numElementsAdded) noexcept |
| This method 'adds' N elements - that were populated using the pointer returned from peekNextAddItems - to the ring buffer. | |
| ITEM * | peekNextRemoveItems (unsigned &dstNumFlatElements) noexcept |
| This method returns a pointer to the next item to be removed. | |
| void | removeElements (unsigned numElementsToRemove) noexcept |
| This method 'removes' N elements - that were removed using the pointer returned from peekNextRemoveItems - from the ring buffer. | |
| bool | isEmpty (void) const noexcept |
| See Cpl::Container::RingBuffer. | |
| bool | isFull (void) const noexcept |
| See Cpl::Container::RingBuffer. | |
| unsigned | getNumItems (void) const noexcept |
| See Cpl::Container::RingBuffer. | |
| unsigned | getMaxItems (void) const noexcept |
| See Cpl::Container::RingBuffer. | |
| void | clearTheBuffer () noexcept |
| See Cpl::Container::RingBuffer. | |
Public Member Functions inherited from Cpl::Container::RingBuffer< ITEM > | |
| RingBuffer (unsigned numElements, ITEM memoryForElements[]) noexcept | |
| Constructor. | |
| bool | remove (ITEM &dst) noexcept |
| Removes the first item in the Buffer. | |
| bool | add (const ITEM &item) noexcept |
| The contents of 'item' will be copied into the Ring Buffer as the 'last' item in the buffer. | |
| ITEM * | peekHead (void) const noexcept |
| Returns a pointer to the first item in the Buffer. | |
| ITEM * | peekTail (void) const noexcept |
| Returns a pointer to the last item in the Buffer. | |
| bool | isEmpty (void) const noexcept |
| This method returns true if the Ring Buffer is empty. | |
| bool | isFull (void) const noexcept |
| This method returns true if the Ring Buffer is full. | |
| unsigned | getNumItems (void) const noexcept |
| This method returns the current number of items in the Ring Buffer. | |
| unsigned | getMaxItems (void) const noexcept |
| This method returns the maximum number of items that can be stored in the Ring buffer. | |
| void | clearTheBuffer () noexcept |
| Empties the Ring Buffer. | |
| ITEM * | peekNextRemoveItems (unsigned &dstNumFlatElements) noexcept |
| This method returns a pointer to the next item to be removed. | |
| void | removeElements (unsigned numElementsToRemove) noexcept |
| This method 'removes' N elements - that were removed using the pointer returned from peekNextRemoveItems - from the ring buffer. | |
| ITEM * | peekNextAddItems (unsigned &dstNumFlatElements) noexcept |
| This method returns a pointer to the next item to be added. | |
| void | addElements (unsigned numElementsAdded) noexcept |
| This method 'adds' N elements - that were populated using the pointer returned from peekNextAddItems - to the ring buffer. | |
Public Attributes | |
| Cpl::Dm::Mp::Uint32 & | m_mpElementCount |
| Model point to report my element count. NOTE: Public access is allowed to simply the application subscribing/accessing the MP. | |
Protected Member Functions | |
| uint16_t | incrementMp () noexcept |
| helper method to increment the MP | |
| uint16_t | decrementMp () noexcept |
| helper method to decrement the MP | |
Additional Inherited Members | |
Protected Attributes inherited from Cpl::Container::RingBufferMT< ITEM > | |
| Cpl::System::Mutex | m_lock |
| Mutex for critical sections. | |
|
inlinenoexcept |
Constructor.
The application is responsible for providing the memory for the Ring Buffer. The argument ''maxElements' is the number of items that will fit in the memory allocated by 'memoryForElements' - it is NOT the number of bytes of 'memoryForElements'.
|
inlinenoexcept |
|
inlinenoexcept |
Extends add() to expose/return the MP's sequence number on the update.
|
inlinenoexcept |
|
inlinenoexcept |
Extends add() to expose/return the MP's sequence number on the update.
|
inlineprotectednoexcept |
helper method to decrement the MP
|
inlineprotectednoexcept |
helper method to increment the MP
|
inlinenoexcept |
|
inlinenoexcept |
Extends remove() to expose/return the MP's sequence number on the update.
| Cpl::Dm::Mp::Uint32& Cpl::Container::RingBufferMP< ITEM >::m_mpElementCount |
Model point to report my element count. NOTE: Public access is allowed to simply the application subscribing/accessing the MP.