|
srs-control 0.2.2
|
Class to manage the production and consumption of LargeBuffer asynchronously. More...
#include <BufferQueue.hpp>

Classes | |
| struct | Config |
| Configuration for the buffer queue class. More... | |
Public Types | |
| using | Token = std::pair<moodycamel::ProducerToken, moodycamel::ConsumerToken> |
| A queue token type used for enqueue and dequeue action. The token type consists of one producer token and one consumer token. | |
Public Member Functions | |
| BufferQueue (const Config &config) | |
| Default constructor. | |
| void | enqueue_empty (std::size_t bulk_size) |
| Abort the blocking operation from BufferQueue::pop(). | |
| auto | enqueue (LargeBuffer &element, Token &token) -> bool |
| Try to first push a buffer into the valid buffer queue and then replace it with a buffer from the trash buffer queue. | |
| void | dequeue (LargeBuffer &element, Token &token) |
| Blocking the current thread by first pushing the element to the trash buffer queue and then replacing it with a buffer from the valid buffer queue. | |
| auto | size () const -> auto |
| Get the current size in the valid buffer queue. | |
| auto | capacity () const -> auto |
| Get the current capacity of the buffer queue. | |
| void | register_report (AppReport &report) |
| auto | get_config () const -> const auto & |
| Getter of the config object. | |
| auto | get_producer_token () -> Token |
| Get a queue token for a producer. The first value is the producer token for the valid_buffer_queue_ and the second value is the consumer token for the trash_buffer_queue_. | |
| auto | get_consumer_token () -> Token |
| Get a queue token for a consumer. The first value is the producer token for the trash_buffer_queue_ and the second value is the consumer token for the valid_buffer_queue_. | |
Private Member Functions | |
| void | print_memory_pre_allocation () |
Private Attributes | |
| Config | config_ |
| std::atomic< std::size_t > | n_trash_recycle_empty_failures_ = 0 |
| std::atomic< std::size_t > | n_trash_recycle_full_failures_ = 0 |
| std::atomic< std::size_t > | n_valid_buffer_full_failures_ = 0 |
| moodycamel::BlockingConcurrentQueue< LargeBuffer > | valid_buffer_queue_ |
| moodycamel::ConcurrentQueue< LargeBuffer > | trash_buffer_queue_ |
| moodycamel::ProducerToken | internal_valid_buffer_token_ { valid_buffer_queue_ } |
| moodycamel::ProducerToken | internal_trash_buffer_token_ { trash_buffer_queue_ } |
Class to manage the production and consumption of LargeBuffer asynchronously.
A BufferQueue contains two subqueues, implemented by the third party library. The first subqueue, called "valid_buffer_queue", stores the incoming buffer read the UDP socket, ready to be consumed by the analysis taskflow. The second subqueue, called "trash_buffer_queue" stores the already analyzed buffer from the taskflow, which can be given back to the UDP socket to read further UDP message.
Definition at line 22 of file BufferQueue.hpp.
| using srs::BufferQueue::Token = std::pair<moodycamel::ProducerToken, moodycamel::ConsumerToken> |
A queue token type used for enqueue and dequeue action. The token type consists of one producer token and one consumer token.
Definition at line 41 of file BufferQueue.hpp.
| srs::BufferQueue::BufferQueue | ( | const Config & | config | ) |
|
inline |
Get the current capacity of the buffer queue.
The capacity represents the maximum number of buffers that can be pushed to the valid buffer queue.
Definition at line 90 of file BufferQueue.hpp.
| void srs::BufferQueue::dequeue | ( | LargeBuffer & | element, |
| Token & | token ) |
Blocking the current thread by first pushing the element to the trash buffer queue and then replacing it with a buffer from the valid buffer queue.
| element | The buffer object to be pushed and replaced. |
Definition at line 80 of file BufferQueue.cpp.
| auto srs::BufferQueue::enqueue | ( | LargeBuffer & | element, |
| Token & | token ) -> bool |
Try to first push a buffer into the valid buffer queue and then replace it with a buffer from the trash buffer queue.
| element | The buffer object to be pushed and replaced. |
Definition at line 63 of file BufferQueue.cpp.
| void srs::BufferQueue::enqueue_empty | ( | std::size_t | bulk_size | ) |
Abort the blocking operation from BufferQueue::pop().
Definition at line 51 of file BufferQueue.cpp.
|
inlinenodiscard |
Getter of the config object.
Definition at line 100 of file BufferQueue.hpp.
|
inlinenodiscard |
Get a queue token for a consumer. The first value is the producer token for the trash_buffer_queue_ and the second value is the consumer token for the valid_buffer_queue_.
Definition at line 116 of file BufferQueue.hpp.
|
inlinenodiscard |
Get a queue token for a producer. The first value is the producer token for the valid_buffer_queue_ and the second value is the consumer token for the trash_buffer_queue_.
Definition at line 106 of file BufferQueue.hpp.
|
private |
Definition at line 33 of file BufferQueue.cpp.
| void srs::BufferQueue::register_report | ( | AppReport & | report | ) |
Definition at line 89 of file BufferQueue.cpp.
|
inline |
Get the current size in the valid buffer queue.
The size of the valid buffer queue means the number of buffers pushed to the queue.
Definition at line 82 of file BufferQueue.hpp.
|
private |
Definition at line 123 of file BufferQueue.hpp.
|
private |
Definition at line 130 of file BufferQueue.hpp.
|
private |
Definition at line 129 of file BufferQueue.hpp.
|
private |
Definition at line 124 of file BufferQueue.hpp.
|
private |
Definition at line 125 of file BufferQueue.hpp.
|
private |
Definition at line 126 of file BufferQueue.hpp.
|
private |
Definition at line 128 of file BufferQueue.hpp.
|
private |
Definition at line 127 of file BufferQueue.hpp.