mal-packet-weaver
C++20 packet serialization/deserialization library.
|
A wrapper class for synchronizing and processing data. More...
Public Member Functions | |
SynchronizationWrapper (boost::asio::io_context &context, std::function< void(std::vector< Value > &)> fn) | |
Constructor for the SynchronizationWrapper class. | |
void | push (Value &&value) |
Pushes a value into the queue for asynchronous processing. | |
void | push (Value &&value) |
bool | has_data () |
Checks if there is data available for processing. | |
std::future< bool > | create_pop_task () |
Creates a task to asynchronously process the enqueued data. | |
Private Attributes | |
boost::asio::io_context::strand | strand_ |
std::atomic_flag | synchronization_flag_ |
std::function< void(std::vector< Value > &)> | dequeue_function_ |
std::vector< Value > | input_data_ |
A wrapper class for synchronizing and processing data.
This class provides a thread-safe mechanism for pushing data into a queue, and asynchronously processing them using a provided processing function.
Value | The type of the data. |
Definition at line 56 of file packet-dispatcher.hpp.
|
inline |
Constructor for the SynchronizationWrapper class.
context | The Boost Asio io_context to be used for strand synchronization. |
fn | A function that processes a vector of key-value pairs. |
Definition at line 65 of file packet-dispatcher.hpp.
|
inline |
Creates a task to asynchronously process the enqueued data.
This function creates a task that processes the enqueued data using the processing function. The promise is set to true
if data was processed, and false
otherwise.
std::future<bool>
indicating the result of data processing. Definition at line 116 of file packet-dispatcher.hpp.
|
inline |
Checks if there is data available for processing.
true
if data is available, false
otherwise. Definition at line 105 of file packet-dispatcher.hpp.
|
inline |
Pushes a value into the queue for asynchronous processing.
The value is enqueued for processing by the processing function. The synchronization flag is set to indicate the availability of data.
key | The key to be pushed. |
Definition at line 77 of file packet-dispatcher.hpp.
|
inline |
Definition at line 87 of file packet-dispatcher.hpp.
|
private |
Function that processes the input data
Definition at line 140 of file packet-dispatcher.hpp.
|
private |
Queue for storing the data
Definition at line 141 of file packet-dispatcher.hpp.
|
private |
Synchronization strand.
Definition at line 138 of file packet-dispatcher.hpp.
|
private |
Atomic flag indicating updates to the data_
Definition at line 139 of file packet-dispatcher.hpp.