Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
urcl::comm::Pipeline< T > Class Template Reference

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 &notifier)
 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 &notifier)
 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_
 
INotifiernotifier_
 
IProducer< T > & producer_
 
std::thread pThread_
 
moodycamel::BlockingReaderWriterQueue< std::unique_ptr< T > > queue_
 
std::atomic< bool > running_
 

Detailed Description

template<typename T>
class urcl::comm::Pipeline< T >

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.

Template Parameters
TType of the managed packages

Definition at line 234 of file pipeline.h.

Member Typedef Documentation

template<typename T>
typedef std::chrono::high_resolution_clock urcl::comm::Pipeline< T >::Clock

Definition at line 237 of file pipeline.h.

template<typename T>
typedef Clock::time_point urcl::comm::Pipeline< T >::Time

Definition at line 238 of file pipeline.h.

Constructor & Destructor Documentation

template<typename T>
urcl::comm::Pipeline< T >::Pipeline ( IProducer< T > &  producer,
IConsumer< T > *  consumer,
std::string  name,
INotifier notifier 
)
inline

Creates a new Pipeline object, registering producer, consumer and notifier. Additionally, an empty queue is initialized.

Parameters
producerThe producer to run in the pipeline
consumerThe consumer to run in the pipeline
nameThe pipeline's name
notifierThe notifier to use

Definition at line 248 of file pipeline.h.

template<typename T>
urcl::comm::Pipeline< T >::Pipeline ( IProducer< T > &  producer,
std::string  name,
INotifier notifier 
)
inline

Creates a new Pipeline object, registering producer and notifier while no consumer is used. Additionally, an empty queue is initialized.

Parameters
producerThe producer to run in the pipeline
nameThe pipeline's name
notifierThe notifier to use

Definition at line 260 of file pipeline.h.

template<typename T>
virtual urcl::comm::Pipeline< T >::~Pipeline ( )
inlinevirtual

The Pipeline object's destructor, stopping the pipeline and joining all running threads.

Definition at line 268 of file pipeline.h.

Member Function Documentation

template<typename T>
bool urcl::comm::Pipeline< T >::getLatestProduct ( std::unique_ptr< T > &  product,
std::chrono::milliseconds  timeout 
)
inline

Returns the next package in the queue. Can be used instead of registering a consumer.

Parameters
productUnique pointer to be set to the package
timeoutTime to wait if no package is in the queue before returning
Returns

Definition at line 329 of file pipeline.h.

template<typename T>
void urcl::comm::Pipeline< T >::init ( )
inline

Definition at line 274 of file pipeline.h.

template<typename T>
void urcl::comm::Pipeline< T >::run ( )
inline

Starts the producer and, if existing, the consumer in new threads.

Definition at line 284 of file pipeline.h.

template<typename T>
void urcl::comm::Pipeline< T >::runConsumer ( )
inlineprivate

Definition at line 422 of file pipeline.h.

template<typename T>
void urcl::comm::Pipeline< T >::runProducer ( )
inlineprivate

Definition at line 343 of file pipeline.h.

template<typename T>
void urcl::comm::Pipeline< T >::stop ( )
inline

Stops the pipeline and all running threads.

Definition at line 300 of file pipeline.h.

Member Data Documentation

template<typename T>
IConsumer<T>* urcl::comm::Pipeline< T >::consumer_
private

Definition at line 336 of file pipeline.h.

template<typename T>
std::thread urcl::comm::Pipeline< T >::cThread_
private

Definition at line 341 of file pipeline.h.

template<typename T>
std::string urcl::comm::Pipeline< T >::name_
private

Definition at line 337 of file pipeline.h.

template<typename T>
INotifier& urcl::comm::Pipeline< T >::notifier_
private

Definition at line 338 of file pipeline.h.

template<typename T>
IProducer<T>& urcl::comm::Pipeline< T >::producer_
private

Definition at line 335 of file pipeline.h.

template<typename T>
std::thread urcl::comm::Pipeline< T >::pThread_
private

Definition at line 341 of file pipeline.h.

template<typename T>
moodycamel::BlockingReaderWriterQueue<std::unique_ptr<T> > urcl::comm::Pipeline< T >::queue_
private

Definition at line 339 of file pipeline.h.

template<typename T>
std::atomic<bool> urcl::comm::Pipeline< T >::running_
private

Definition at line 340 of file pipeline.h.


The documentation for this class was generated from the following file:


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Sun May 9 2021 02:16:26