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 most recent package in the queue. Can be used instead of registering a consumer. If the queue already contains one or more items, the queue will be flushed and the newest item will be returned. If there is no item inside the queue, the function will wait for timeout for a new package. More... | |
void | init () |
Pipeline (IProducer< T > &producer, IConsumer< T > *consumer, std::string name, INotifier ¬ifier, const bool producer_fifo_scheduling=false) | |
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, const bool producer_fifo_scheduling=false) | |
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_ |
bool | producer_fifo_scheduling_ |
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 235 of file pipeline.h.
typedef std::chrono::high_resolution_clock urcl::comm::Pipeline< T >::Clock |
Definition at line 238 of file pipeline.h.
typedef Clock::time_point urcl::comm::Pipeline< T >::Time |
Definition at line 239 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 |
producer_fifo_scheduling | Should the producer thread use FIFO scheduling? |
Definition at line 250 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 |
producer_fifo_scheduling | Should the producer thread use FIFO scheduling? |
Definition at line 270 of file pipeline.h.
|
inlinevirtual |
The Pipeline object's destructor, stopping the pipeline and joining all running threads.
Definition at line 284 of file pipeline.h.
|
inline |
Returns the most recent package in the queue. Can be used instead of registering a consumer. If the queue already contains one or more items, the queue will be flushed and the newest item will be returned. If there is no item inside the queue, the function will wait for timeout
for a new package.
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 347 of file pipeline.h.
|
inline |
Definition at line 290 of file pipeline.h.
|
inline |
Starts the producer and, if existing, the consumer in new threads.
Definition at line 300 of file pipeline.h.
|
inlineprivate |
Definition at line 403 of file pipeline.h.
|
inlineprivate |
Definition at line 370 of file pipeline.h.
|
inline |
Stops the pipeline and all running threads.
Definition at line 316 of file pipeline.h.
|
private |
Definition at line 362 of file pipeline.h.
|
private |
Definition at line 367 of file pipeline.h.
|
private |
Definition at line 363 of file pipeline.h.
|
private |
Definition at line 364 of file pipeline.h.
|
private |
Definition at line 361 of file pipeline.h.
|
private |
Definition at line 368 of file pipeline.h.
|
private |
Definition at line 367 of file pipeline.h.
|
private |
Definition at line 365 of file pipeline.h.
|
private |
Definition at line 366 of file pipeline.h.