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 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 &notifier, 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 &notifier, 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_
 
INotifiernotifier_
 
IProducer< T > & producer_
 
bool producer_fifo_scheduling_
 
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 235 of file pipeline.h.

Member Typedef Documentation

◆ Clock

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

Definition at line 238 of file pipeline.h.

◆ Time

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

Definition at line 239 of file pipeline.h.

Constructor & Destructor Documentation

◆ Pipeline() [1/2]

template<typename T>
urcl::comm::Pipeline< T >::Pipeline ( IProducer< T > &  producer,
IConsumer< T > *  consumer,
std::string  name,
INotifier notifier,
const bool  producer_fifo_scheduling = false 
)
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
producer_fifo_schedulingShould the producer thread use FIFO scheduling?

Definition at line 250 of file pipeline.h.

◆ Pipeline() [2/2]

template<typename T>
urcl::comm::Pipeline< T >::Pipeline ( IProducer< T > &  producer,
std::string  name,
INotifier notifier,
const bool  producer_fifo_scheduling = false 
)
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
producer_fifo_schedulingShould the producer thread use FIFO scheduling?

Definition at line 270 of file pipeline.h.

◆ ~Pipeline()

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 284 of file pipeline.h.

Member Function Documentation

◆ getLatestProduct()

template<typename T>
bool urcl::comm::Pipeline< T >::getLatestProduct ( std::unique_ptr< T > &  product,
std::chrono::milliseconds  timeout 
)
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.

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 347 of file pipeline.h.

◆ init()

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

Definition at line 290 of file pipeline.h.

◆ run()

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

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

Definition at line 300 of file pipeline.h.

◆ runConsumer()

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

Definition at line 403 of file pipeline.h.

◆ runProducer()

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

Definition at line 370 of file pipeline.h.

◆ stop()

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

Stops the pipeline and all running threads.

Definition at line 316 of file pipeline.h.

Member Data Documentation

◆ consumer_

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

Definition at line 362 of file pipeline.h.

◆ cThread_

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

Definition at line 367 of file pipeline.h.

◆ name_

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

Definition at line 363 of file pipeline.h.

◆ notifier_

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

Definition at line 364 of file pipeline.h.

◆ producer_

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

Definition at line 361 of file pipeline.h.

◆ producer_fifo_scheduling_

template<typename T>
bool urcl::comm::Pipeline< T >::producer_fifo_scheduling_
private

Definition at line 368 of file pipeline.h.

◆ pThread_

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

Definition at line 367 of file pipeline.h.

◆ queue_

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

Definition at line 365 of file pipeline.h.

◆ running_

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

Definition at line 366 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 Tue Jul 4 2023 02:09:47