The Pipepline manages the production and optionally consumption of packages. Cyclically the producer is called and returned packages are saved in a queue. This queue is then either also cyclically utilized by the registered consumer or can be externally used. More...
#include <pipeline.h>
Public Types | |
typedef std::chrono::high_resolution_clock | Clock |
typedef Clock::time_point | Time |
Public Member Functions | |
bool | getLatestProduct (std::unique_ptr< T > &product, std::chrono::milliseconds timeout) |
Returns the next package in the queue. Can be used instead of registering a consumer. More... | |
void | init () |
Pipeline (IProducer< T > &producer, IConsumer< T > *consumer, std::string name, INotifier ¬ifier) | |
Creates a new Pipeline object, registering producer, consumer and notifier. Additionally, an empty queue is initialized. More... | |
Pipeline (IProducer< T > &producer, std::string name, INotifier ¬ifier) | |
Creates a new Pipeline object, registering producer and notifier while no consumer is used. Additionally, an empty queue is initialized. More... | |
void | run () |
Starts the producer and, if existing, the consumer in new threads. More... | |
void | stop () |
Stops the pipeline and all running threads. More... | |
virtual | ~Pipeline () |
The Pipeline object's destructor, stopping the pipeline and joining all running threads. More... | |
Private Member Functions | |
void | runConsumer () |
void | runProducer () |
Private Attributes | |
IConsumer< T > * | consumer_ |
std::thread | cThread_ |
std::string | name_ |
INotifier & | notifier_ |
IProducer< T > & | producer_ |
std::thread | pThread_ |
moodycamel::BlockingReaderWriterQueue< std::unique_ptr< T > > | queue_ |
std::atomic< bool > | running_ |
The Pipepline manages the production and optionally consumption of packages. Cyclically the producer is called and returned packages are saved in a queue. This queue is then either also cyclically utilized by the registered consumer or can be externally used.
T | Type of the managed packages |
Definition at line 234 of file pipeline.h.
typedef std::chrono::high_resolution_clock urcl::comm::Pipeline< T >::Clock |
Definition at line 237 of file pipeline.h.
typedef Clock::time_point urcl::comm::Pipeline< T >::Time |
Definition at line 238 of file pipeline.h.
|
inline |
Creates a new Pipeline object, registering producer, consumer and notifier. Additionally, an empty queue is initialized.
producer | The producer to run in the pipeline |
consumer | The consumer to run in the pipeline |
name | The pipeline's name |
notifier | The notifier to use |
Definition at line 248 of file pipeline.h.
|
inline |
Creates a new Pipeline object, registering producer and notifier while no consumer is used. Additionally, an empty queue is initialized.
producer | The producer to run in the pipeline |
name | The pipeline's name |
notifier | The notifier to use |
Definition at line 260 of file pipeline.h.
|
inlinevirtual |
The Pipeline object's destructor, stopping the pipeline and joining all running threads.
Definition at line 268 of file pipeline.h.
|
inline |
Returns the next package in the queue. Can be used instead of registering a consumer.
product | Unique pointer to be set to the package |
timeout | Time to wait if no package is in the queue before returning |
Definition at line 329 of file pipeline.h.
|
inline |
Definition at line 274 of file pipeline.h.
|
inline |
Starts the producer and, if existing, the consumer in new threads.
Definition at line 284 of file pipeline.h.
|
inlineprivate |
Definition at line 422 of file pipeline.h.
|
inlineprivate |
Definition at line 343 of file pipeline.h.
|
inline |
Stops the pipeline and all running threads.
Definition at line 300 of file pipeline.h.
|
private |
Definition at line 336 of file pipeline.h.
|
private |
Definition at line 341 of file pipeline.h.
|
private |
Definition at line 337 of file pipeline.h.
|
private |
Definition at line 338 of file pipeline.h.
|
private |
Definition at line 335 of file pipeline.h.
|
private |
Definition at line 341 of file pipeline.h.
|
private |
Definition at line 339 of file pipeline.h.
|
private |
Definition at line 340 of file pipeline.h.