|
Core Library
1.7.0.0
Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.
|
Class defining a bounded buffer. More...
#include <BoundedBuffer.h>
Public Types | |
| using | container_type = boost::circular_buffer< T > |
| Typedef for container type. | |
| using | size_type = typename container_type::size_type |
| Typedef for container size type. | |
| using | value_type = typename container_type::value_type |
| Typedef for container value type. | |
| using | param_type = typename boost::call_traits< value_type >::param_type |
| Typedef for container param type. | |
Public Member Functions | |
| BoundedBuffer (size_type capacity) | |
| Constructor. More... | |
| ~BoundedBuffer ()=default | |
| Default destructor. | |
| BoundedBuffer (const BoundedBuffer &)=delete | |
| Copy constructor deleted. | |
| BoundedBuffer & | operator= (const BoundedBuffer &)=delete |
| Copy assignment operator deleted. | |
| BoundedBuffer (BoundedBuffer &&)=delete | |
| Move constructor deleted. | |
| BoundedBuffer & | operator= (BoundedBuffer &&)=delete |
| Move assignment operator deleted. | |
| void | PushFront (param_type item) |
| Push new item to the front. More... | |
| void | PopBack (value_type &item) |
| Pop item from the back. More... | |
Private Member Functions | |
| bool | IsNotEmpty () const |
| Test if buffer not empty. More... | |
| bool | IsNotFull () const |
| Test if buffer not full. More... | |
Private Attributes | |
| std::mutex | m_mutex |
| Synchronization mutex. | |
| std::condition_variable | m_notEmptyEvent |
| Condition variable to flag not empty. | |
| std::condition_variable | m_notFullEvent |
| Condition variable to flag not full. | |
| size_type | m_unreadCount {0} |
| Unread count. | |
| container_type | m_container {} |
| Circular buffer. | |
Class defining a bounded buffer.
This class implements a fully thread-safe bounded circular buffer that blocks the consumer thread when empty and blocks the producer thread when full. It acts like a bounded single producer/single consumer queue.
This code is based on the example given in the boost circular buffer documentation.
|
inlineexplicit |
Constructor.
| [in] | capacity | - The capacity for the underlying circular buffer. |
|
inlineprivate |
Test if buffer not empty.
|
inlineprivate |
Test if buffer not full.
|
inline |
Pop item from the back.
| [out] | item | - The item to pop from the back. |
This function blocks if the buffer is at capacity.
|
inline |
Push new item to the front.
| [in] | item | - The item to push to the front. |
This function blocks if the buffer is at capacity.