|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Thread-safe lock-free MPMC (Multiple Producer Multiple Consumer) queue. More...
#include <lockfree_queue.h>

Classes | |
| struct | slot |
Public Member Functions | |
| lockfree_queue () | |
| Default constructor with default configuration. | |
| lockfree_queue (const lockfree_queue_config &config) | |
| Construct with configuration. | |
| lockfree_queue (const lockfree_queue &)=delete | |
| lockfree_queue & | operator= (const lockfree_queue &)=delete |
| lockfree_queue (lockfree_queue &&other) noexcept | |
| lockfree_queue & | operator= (lockfree_queue &&other) noexcept |
| common::Result< bool > | push (const T &value) |
| Push an element to the queue. | |
| common::Result< bool > | push (T &&value) |
| Push an element to the queue (move version) | |
| common::Result< T > | pop () |
| Pop an element from the queue. | |
| bool | empty () const |
| Check if the queue is empty. | |
| size_t | size () const |
| Get current queue size. | |
| size_t | capacity () const |
| Get queue capacity. | |
| const lockfree_queue_statistics & | get_statistics () const |
| Get queue statistics. | |
| void | reset_statistics () |
| Reset statistics. | |
Private Member Functions | |
| template<typename U > | |
| common::Result< bool > | push_impl (U &&value) |
Private Attributes | |
| lockfree_queue_config | config_ |
| size_t | capacity_ |
| std::vector< slot > | buffer_ |
| std::atomic< size_t > | head_ |
| std::atomic< size_t > | tail_ |
| std::atomic< size_t > | size_ |
| lockfree_queue_statistics | stats_ |
Thread-safe lock-free MPMC (Multiple Producer Multiple Consumer) queue.
This implementation uses a bounded ring buffer with atomic operations for thread-safe access without locks.
| T | The type of elements stored in the queue |
Definition at line 120 of file lockfree_queue.h.
|
inline |
Default constructor with default configuration.
Definition at line 125 of file lockfree_queue.h.
|
inlineexplicit |
Construct with configuration.
| config | Queue configuration |
Definition at line 131 of file lockfree_queue.h.
References kcenon::monitoring::lockfree_queue< T >::buffer_, and kcenon::monitoring::lockfree_queue< T >::capacity_.
|
delete |
|
inlinenoexcept |
Definition at line 149 of file lockfree_queue.h.
|
inline |
Get queue capacity.
Definition at line 245 of file lockfree_queue.h.
References kcenon::monitoring::lockfree_queue< T >::capacity_.
|
inline |
Check if the queue is empty.
Definition at line 229 of file lockfree_queue.h.
References kcenon::monitoring::lockfree_queue< T >::size_.
Referenced by TEST_F(), TEST_F(), TEST_F(), and TEST_F().

|
inline |
Get queue statistics.
Definition at line 253 of file lockfree_queue.h.
References kcenon::monitoring::lockfree_queue< T >::stats_.
Referenced by TEST_F(), TEST_F(), and TEST_F().

|
delete |
|
inlinenoexcept |
Definition at line 158 of file lockfree_queue.h.
References kcenon::monitoring::lockfree_queue< T >::buffer_, kcenon::monitoring::lockfree_queue< T >::capacity_, kcenon::monitoring::lockfree_queue< T >::config_, kcenon::monitoring::lockfree_queue< T >::head_, kcenon::monitoring::other, kcenon::monitoring::lockfree_queue< T >::size_, kcenon::monitoring::lockfree_queue< T >::stats_, and kcenon::monitoring::lockfree_queue< T >::tail_.
|
inline |
Pop an element from the queue.
Definition at line 193 of file lockfree_queue.h.
References kcenon::monitoring::lockfree_queue< T >::buffer_, kcenon::monitoring::lockfree_queue< T >::capacity_, kcenon::monitoring::lockfree_queue< T >::slot::data, kcenon::monitoring::lockfree_queue< T >::head_, kcenon::monitoring::lockfree_queue_statistics::pop_attempts, kcenon::monitoring::lockfree_queue_statistics::pop_failures, kcenon::monitoring::lockfree_queue_statistics::pop_successes, kcenon::monitoring::resource_unavailable, kcenon::monitoring::lockfree_queue< T >::slot::sequence, kcenon::monitoring::lockfree_queue< T >::size_, and kcenon::monitoring::lockfree_queue< T >::stats_.
Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

|
inline |
Push an element to the queue.
| value | The value to push |
Definition at line 176 of file lockfree_queue.h.
References kcenon::monitoring::lockfree_queue< T >::push_impl().
Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().


|
inline |
Push an element to the queue (move version)
| value | The value to push |
Definition at line 185 of file lockfree_queue.h.
References kcenon::monitoring::lockfree_queue< T >::push_impl().

|
inlineprivate |
Definition at line 271 of file lockfree_queue.h.
References kcenon::monitoring::lockfree_queue< T >::buffer_, kcenon::monitoring::lockfree_queue< T >::capacity_, kcenon::monitoring::lockfree_queue< T >::slot::data, kcenon::monitoring::lockfree_queue_statistics::push_attempts, kcenon::monitoring::lockfree_queue_statistics::push_failures, kcenon::monitoring::lockfree_queue_statistics::push_successes, kcenon::monitoring::lockfree_queue< T >::slot::sequence, kcenon::monitoring::lockfree_queue< T >::size_, kcenon::monitoring::lockfree_queue< T >::stats_, and kcenon::monitoring::lockfree_queue< T >::tail_.
Referenced by kcenon::monitoring::lockfree_queue< T >::push(), and kcenon::monitoring::lockfree_queue< T >::push().

|
inline |
Reset statistics.
Definition at line 260 of file lockfree_queue.h.
References kcenon::monitoring::lockfree_queue_statistics::reset(), and kcenon::monitoring::lockfree_queue< T >::stats_.
Referenced by TEST_F().


|
inline |
Get current queue size.
Definition at line 237 of file lockfree_queue.h.
References kcenon::monitoring::lockfree_queue< T >::size_.
Referenced by TEST_F(), TEST_F(), and TEST_F().

|
private |
|
private |
Definition at line 304 of file lockfree_queue.h.
Referenced by kcenon::monitoring::lockfree_queue< T >::capacity(), kcenon::monitoring::lockfree_queue< T >::lockfree_queue(), kcenon::monitoring::lockfree_queue< T >::operator=(), kcenon::monitoring::lockfree_queue< T >::pop(), and kcenon::monitoring::lockfree_queue< T >::push_impl().
|
private |
Definition at line 303 of file lockfree_queue.h.
Referenced by kcenon::monitoring::lockfree_queue< T >::operator=().
|
private |
Definition at line 306 of file lockfree_queue.h.
Referenced by kcenon::monitoring::lockfree_queue< T >::operator=(), and kcenon::monitoring::lockfree_queue< T >::pop().
|
private |
Definition at line 308 of file lockfree_queue.h.
Referenced by kcenon::monitoring::lockfree_queue< T >::empty(), kcenon::monitoring::lockfree_queue< T >::operator=(), kcenon::monitoring::lockfree_queue< T >::pop(), kcenon::monitoring::lockfree_queue< T >::push_impl(), and kcenon::monitoring::lockfree_queue< T >::size().
|
mutableprivate |
Definition at line 309 of file lockfree_queue.h.
Referenced by kcenon::monitoring::lockfree_queue< T >::get_statistics(), kcenon::monitoring::lockfree_queue< T >::operator=(), kcenon::monitoring::lockfree_queue< T >::pop(), kcenon::monitoring::lockfree_queue< T >::push_impl(), and kcenon::monitoring::lockfree_queue< T >::reset_statistics().
|
private |
Definition at line 307 of file lockfree_queue.h.
Referenced by kcenon::monitoring::lockfree_queue< T >::operator=(), and kcenon::monitoring::lockfree_queue< T >::push_impl().