DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
QueueSenderModel.hxx
Go to the documentation of this file.
1
5
6#include "logging/Logging.hpp"
7
8#include <memory>
9#include <string>
10#include <typeinfo>
11#include <utility>
12
13namespace dunedaq::iomanager {
14
15template<typename Datatype>
16inline void
17QueueSenderModel<Datatype>::send_with_topic(Datatype&& data, Sender::timeout_t timeout, std::string) // NOLINT
18{
19 // Topics are not used for Queues
20 send(std::move(data), timeout);
21}
22
23template<typename Datatype>
24inline bool
26{
27 if (m_queue == nullptr) {
28 ers::error(ConnectionInstanceNotFound(ERS_HERE, this->id().uid));
29 return false;
30 }
31
32 return m_queue->try_push(std::move(data), timeout);
33}
34
35template<typename Datatype>
36inline void
37QueueSenderModel<Datatype>::send(Datatype&& data, Sender::timeout_t timeout) // NOLINT
38{
39 if (m_queue == nullptr)
40 throw ConnectionInstanceNotFound(ERS_HERE, this->id().uid);
41
42 try {
43 m_queue->push(std::move(data), timeout);
44 } catch (QueueTimeoutExpired& ex) {
45 throw TimeoutExpired(ERS_HERE, this->id().uid, "push", timeout.count(), ex);
46 }
47}
48
49template<typename Datatype>
50inline bool
52{
53 // Queues are always ready
54 return true;
55}
56
57template<typename Datatype>
59 : SenderConcept<Datatype>(other.m_conn.uid)
60 , m_queue(std::move(other.m_queue))
61{
62}
63
64template<typename Datatype>
66 : SenderConcept<Datatype>(request)
67{
68 TLOG("QueueSenderModel") << "QueueSenderModel created with DT! Addr: " << static_cast<void*>(this);
69 m_queue = QueueRegistry::get().get_queue<Datatype>(request.uid);
70 TLOG("QueueSenderModel") << "QueueSenderModel m_queue=" << static_cast<void*>(m_queue.get());
71 // get queue ref from queueregistry based on conn_id
72}
73
74} // namespace dunedaq::iomanager
#define ERS_HERE
static QueueRegistry & get()
Get a handle to the QueueRegistry.
std::shared_ptr< Queue< T > > get_queue(const std::string &name)
Get a handle to a Queue.
bool try_send(Datatype &&data, Sender::timeout_t timeout) override
bool is_ready_for_sending(Sender::timeout_t timeout) override
std::shared_ptr< Queue< Datatype > > m_queue
void send_with_topic(Datatype &&data, Sender::timeout_t timeout, std::string) override
QueueSenderModel(ConnectionId const &request)
void send(Datatype &&data, Sender::timeout_t timeout) override
std::chrono::milliseconds timeout_t
Definition Sender.hpp:24
#define TLOG(...)
Definition macro.hpp:22
void error(const Issue &issue)
Definition ers.hpp:81