DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Queue.hpp
Go to the documentation of this file.
1
14#ifndef IOMANAGER_INCLUDE_IOMANAGER_QUEUE_QUEUE_HPP_
15#define IOMANAGER_INCLUDE_IOMANAGER_QUEUE_QUEUE_HPP_
16
19
20#include "ers/Issue.hpp"
21#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
22
23#include <chrono>
24#include <cstddef>
25#include <memory>
26#include <string>
27#include <vector>
28
29namespace dunedaq::iomanager {
30
35template<class T>
36class Queue : public QueueBase
37{
38public:
39 using value_t = T;
40 using duration_t = std::chrono::milliseconds;
41
46 explicit Queue(const std::string& name)
47 : QueueBase(name)
48 {
49 }
50
56 virtual bool can_push() const { return this->get_num_elements() < this->get_capacity(); }
57
63 virtual bool can_pop() const { return this->get_num_elements() > 0; }
64
74 virtual void push(value_t&& val, const duration_t& timeout) = 0;
75
85 virtual void pop(value_t& val, const duration_t& timeout) = 0;
86
87 virtual bool try_push(value_t&& val, const duration_t& timeout) = 0;
88 virtual bool try_pop(value_t& val, const duration_t& timeout) = 0;
89
90private:
91 Queue(const Queue&) = delete;
92 Queue& operator=(const Queue&) = delete;
93 Queue(Queue&&) = delete;
94 Queue& operator=(Queue&&) = delete;
95};
96
97} // namespace dunedaq::iomanager
98
99#endif // IOMANAGER_INCLUDE_IOMANAGER_QUEUE_QUEUE_HPP_
The QueueBase class allows to address generic behavior of any Queue implementation.
Definition QueueBase.hpp:45
virtual size_t get_num_elements() const =0
virtual size_t get_capacity() const =0
Get the capacity (max size) of the queue.
Implementations of the Queue class are responsible for relaying data between DAQModules within a DAQ ...
Definition Queue.hpp:37
virtual bool can_pop() const
Determine whether the Queue may be popped from.
Definition Queue.hpp:63
Queue(const Queue &)=delete
virtual void pop(value_t &val, const duration_t &timeout)=0
Pop the first value off of the queue.
Queue & operator=(Queue &&)=delete
virtual void push(value_t &&val, const duration_t &timeout)=0
Push a value onto the Queue.
virtual bool try_push(value_t &&val, const duration_t &timeout)=0
virtual bool can_push() const
Determine whether the Queue may be pushed onto.
Definition Queue.hpp:56
std::chrono::milliseconds duration_t
Base duration type for timeouts.
Definition Queue.hpp:40
Queue(const std::string &name)
Queue Constructor.
Definition Queue.hpp:46
Queue & operator=(const Queue &)=delete
T value_t
Type stored in the Queue.
Definition Queue.hpp:39
virtual bool try_pop(value_t &val, const duration_t &timeout)=0
Queue(Queue &&)=delete