Go to the documentation of this file.
83 virtual bool consume(std::shared_ptr<T> product) = 0;
130 URCL_LOG_ERROR(
"Unable to remove consumer as it is not part of the consumer list");
143 con->setupConsumer();
153 con->teardownConsumer();
190 if (!con->consume(product))
205 template <
typename T>
219 const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10))
247 virtual bool tryGet(std::vector<std::unique_ptr<T>>& products) = 0;
277 template <
typename T>
281 typedef std::chrono::high_resolution_clock
Clock;
282 typedef Clock::time_point
Time;
294 const bool producer_fifo_scheduling =
false)
340 void init(
const size_t max_num_tries = 0,
341 const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10))
343 producer_.setupProducer(max_num_tries, reconnection_time);
426 pthread_t this_thread = pthread_self();
427 const int max_thread_priority = sched_get_priority_max(SCHED_FIFO);
430 std::vector<std::unique_ptr<T>> products;
440 for (
auto& p : products)
456 std::unique_ptr<T> product;
469 if (!
consumer_->consume(std::move(product)))
bool setFiFoScheduling(pthread_t &thread, const int priority)
virtual void stopped(std::string name)
Stop notification.
virtual void teardownConsumer()
Fully tears down the consumer - by default no difference to stopping it.
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....
Consumer, that allows one product to be consumed by multiple arbitrary consumers.
bool waitDequeTimed(U &result, std::int64_t timeout_usecs)
virtual bool consume(std::shared_ptr< T > product)=0
Consumes a product, utilizing it's contents.
virtual ~IConsumer()=default
bool consume(std::shared_ptr< T > product)
Consumes a given product with all registered consumers.
#define URCL_LOG_ERROR(...)
virtual void setupConsumer()
Set-up functionality of the consumer.
void stop()
Stops the pipeline and all running threads.
virtual void teardownConsumer()
Tears down all registered consumers.
virtual void startProducer()
IProducer< T > & producer_
#define URCL_LOG_DEBUG(...)
IConsumer< T > * consumer_
Parent class for arbitrary producers of packages.
virtual bool tryGet(std::vector< std::unique_ptr< T >> &products)=0
Reads packages from some source and produces corresponding objects.
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....
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,...
virtual void stopConsumer()
Stops the consumer.
Parent class for notifiers.
virtual ~IProducer()=default
virtual void stopProducer()
Stops the producer.
std::mutex consumer_list_
The Pipeline manages the production and optionally consumption of packages. Cyclically the producer i...
bool producer_fifo_scheduling_
virtual void stopConsumer()
Stops all registered consumers.
std::chrono::high_resolution_clock Clock
bool tryDequeue(U &result)
MultiConsumer(std::vector< std::shared_ptr< IConsumer< T >>> consumers)
Creates a new MultiConsumer object.
AE_FORCEINLINE bool tryEnqueue(T const &element)
Parent class for for arbitrary consumers.
virtual void teardownProducer()
Fully tears down the producer - by default no difference to stopping it.
virtual void onTimeout()
Triggers timeout functionality for all registered consumers.
virtual ~Pipeline()
The Pipeline object's destructor, stopping the pipeline and joining all running threads.
moodycamel::BlockingReaderWriterQueue< std::unique_ptr< T > > queue_
virtual void onTimeout()
Functionality for handling consumer timeouts.
void init(const size_t max_num_tries=0, const std::chrono::milliseconds reconnection_time=std::chrono::seconds(10))
Initialize the pipeline. Internally calls setup of producer and consumer.
virtual void setupProducer(const size_t max_num_tries=0, const std::chrono::milliseconds reconnection_time=std::chrono::seconds(10))
Set-up functionality of the producers.
void run()
Starts the producer and, if existing, the consumer in new threads.
std::atomic< bool > running_
virtual void started(std::string name)
Start notification.
void removeConsumer(std::shared_ptr< IConsumer< T >> consumer)
Remove a consumer from the list of consumers.
virtual void setupConsumer()
Sets up all registered consumers.
void addConsumer(std::shared_ptr< IConsumer< T >> consumer)
Adds a new consumer to the list of consumers.
std::vector< std::shared_ptr< IConsumer< T > > > consumers_
ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Mon May 26 2025 02:35:58