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_HPP_
15#define IOMANAGER_INCLUDE_IOMANAGER_QUEUE_HPP_
16
18
19#include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
20#include "ers/Issue.hpp"
21
22#include <chrono>
23#include <cstddef>
24#include <memory>
25#include <string>
26#include <vector>
27
28namespace dunedaq {
29namespace iomanager {
30
38template<class T>
39class Queue : public QueueBase
40{
41public:
42 using value_t = T;
43 using duration_t = std::chrono::milliseconds;
44
49 explicit Queue(const std::string& name)
50 : QueueBase(name)
51 {}
52
58 virtual bool can_push() const { return this->get_num_elements() < this->get_capacity(); }
59
65 virtual bool can_pop() const { return this->get_num_elements() > 0; }
66
76 virtual void push(value_t&& val, const duration_t& timeout) = 0;
77
87 virtual void pop(value_t& val, const duration_t& timeout) = 0;
88
89 virtual bool try_push(value_t&& val, const duration_t& timeout) = 0;
90 virtual bool try_pop(value_t& val, const duration_t& timeout) = 0;
91
92private:
93 Queue(const Queue&) = delete;
94 Queue& operator=(const Queue&) = delete;
95 Queue(Queue&&) = default;
96 Queue& operator=(Queue&&) = default;
97};
98
99} // namespace iomanager
100// Disable coverage collection LCOV_EXCL_START
104ERS_DECLARE_ISSUE(iomanager, // namespace
105 QueueTimeoutExpired, // issue class name
106 name << ": Unable to " << func_name << " within timeout period (timeout period was " << timeout
107 << " milliseconds)", // message
108 ((std::string)name)((std::string)func_name)((int)timeout)) // NOLINT(readability/casting)
109// Re-enable coverage collection LCOV_EXCL_STOP
110} // namespace dunedaq
111
112#endif // IOMANAGER_INCLUDE_IOMANAGER_QUEUE_HPP_
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
The QueueBase class allows to address generic behavior of any Queue implementation.
Definition QueueBase.hpp:39
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:40
virtual bool can_pop() const
Determine whether the Queue may be popped from.
Definition Queue.hpp:65
Queue(const Queue &)=delete
Queue(Queue &&)=default
virtual void pop(value_t &val, const duration_t &timeout)=0
Pop the first value off of the queue.
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:58
std::chrono::milliseconds duration_t
Base duration type for timeouts.
Definition Queue.hpp:43
Queue & operator=(Queue &&)=default
Queue(const std::string &name)
Queue Constructor.
Definition Queue.hpp:49
Queue & operator=(const Queue &)=delete
T value_t
Type stored in the Queue.
Definition Queue.hpp:42
virtual bool try_pop(value_t &val, const duration_t &timeout)=0
Including Qt Headers.