Template class implementing an asynchronous processing pipeline. More...
#include <AsyncPipeline.hxx>
Public Member Functions | |
| AsyncPipeline & | startService () |
| Starts the pipeline service. | |
| void | stopService () |
| Stops the pipeline service. | |
| template<typename T > | |
| uint64_t | send (T &&object) |
| Sends an object to the pipeline for asynchronous processing. | |
| template<typename T > | |
| uint64_t | sendSync (T &&object) |
| Sends an object to the pipeline and waits for processing completion. | |
| int | pause () |
| Pauses the pipeline processing. | |
| int | resume () |
| Resumes the pipeline processing. | |
| AsyncPipeline< ObjectType > & | registerAsyncHandler (std::string handlerName, std::function< void(const ObjectType &object)> handler) |
| Registers an asynchronous handler for processing objects. | |
| std::optional< ObjectType > | selectDataByCondition (const std::function< bool(const ObjectType &)> &condition, const std::chrono::milliseconds &maxWait_ms, std::optional< std::string > conditionName) |
| Selects data from the pipeline based on a condition. | |
| AsyncPipeline< ObjectType > & | unregisterHandler (const std::string &handlerName) |
| Unregisters a handler from the pipeline. | |
| bool | hasHandler (const std::string &handlerName) |
| Checks if a handler exists in the pipeline. | |
| bool | isPipelineRunning () const |
| Checks if the pipeline is currently running. | |
| bool | isPipelinePaused () const |
| Checks if the pipeline is currently paused. | |
Template class implementing an asynchronous processing pipeline.
AsyncPipeline provides a thread-safe mechanism for processing objects asynchronously through a series of registered handlers. It supports operations like starting, stopping, pausing, and resuming the pipeline, as well as synchronous and asynchronous object processing.
| ObjectType | The type of objects to be processed in the pipeline |
Definition at line 24 of file AsyncPipeline.hxx.
|
inline |
Checks if a handler exists in the pipeline.
| handlerName | Name of the handler to check |
Definition at line 194 of file AsyncPipeline.hxx.
|
inline |
Checks if the pipeline is currently paused.
Definition at line 212 of file AsyncPipeline.hxx.
|
inline |
Checks if the pipeline is currently running.
Definition at line 203 of file AsyncPipeline.hxx.
|
inline |
Pauses the pipeline processing.
Definition at line 109 of file AsyncPipeline.hxx.
|
inline |
Registers an asynchronous handler for processing objects.
| handlerName | Unique name for the handler |
| handler | Function to process objects of ObjectType |
Definition at line 133 of file AsyncPipeline.hxx.
Referenced by AsyncPipeline< ObjectType >::selectDataByCondition().
|
inline |
Resumes the pipeline processing.
Definition at line 120 of file AsyncPipeline.hxx.
|
inline |
Selects data from the pipeline based on a condition.
| condition | Function that evaluates whether an object meets the selection criteria |
| maxWait_ms | Maximum time to wait for matching data |
| conditionName | Optional name for the condition handler |
Definition at line 148 of file AsyncPipeline.hxx.
References AsyncPipeline< ObjectType >::registerAsyncHandler(), and AsyncPipeline< ObjectType >::unregisterHandler().
|
inline |
Sends an object to the pipeline for asynchronous processing.
| T | Type of the object being sent (enables perfect forwarding) |
| object | Object to be processed |
Definition at line 73 of file AsyncPipeline.hxx.
Referenced by AsyncPipeline< ObjectType >::sendSync().
|
inline |
Sends an object to the pipeline and waits for processing completion.
| T | Type of the object being sent (enables perfect forwarding) |
| object | Object to be processed |
Definition at line 90 of file AsyncPipeline.hxx.
References AsyncPipeline< ObjectType >::send().
|
inline |
Starts the pipeline service.
Initializes the pipeline state and starts the service loop in a separate thread.
Definition at line 33 of file AsyncPipeline.hxx.
References Singleton< T >::getInstance().
|
inline |
Stops the pipeline service.
Stops the pipeline, clears all handlers and buffered objects, and waits for completion.
Definition at line 49 of file AsyncPipeline.hxx.
|
inline |
Unregisters a handler from the pipeline.
| handlerName | Name of the handler to remove |
Definition at line 179 of file AsyncPipeline.hxx.
Referenced by AsyncPipeline< ObjectType >::selectDataByCondition().