Line data Source code
1 : /**
2 : * @file Sender.hpp Sender Class implementations
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "ipm/Sender.hpp"
10 : #include "ipm/opmon/ipm.pb.h"
11 :
12 : #include <string>
13 : #include <utility>
14 : #include <vector>
15 :
16 : bool
17 20052 : dunedaq::ipm::Sender::send(const void* message,
18 : message_size_t message_size,
19 : const duration_t& timeout,
20 : std::string const& metadata,
21 : bool no_tmoexcept_mode)
22 : {
23 20052 : if (message_size == 0) {
24 : return true;
25 : }
26 :
27 20051 : if (!can_send()) {
28 1 : throw KnownStateForbidsSend(ERS_HERE);
29 : }
30 :
31 20050 : if (!message) {
32 1 : throw NullPointerPassedToSend(ERS_HERE);
33 : }
34 :
35 20049 : auto res = send_(message, message_size, timeout, metadata, no_tmoexcept_mode);
36 :
37 20048 : m_bytes += message_size;
38 20048 : ++m_messages;
39 :
40 20048 : return res;
41 : }
42 :
43 : void
44 21 : dunedaq::ipm::Sender::generate_opmon_data()
45 : {
46 :
47 21 : opmon::SenderInfo i;
48 :
49 21 : i.set_bytes(m_bytes.exchange(0));
50 21 : i.set_messages(m_messages.exchange(0));
51 :
52 21 : publish(std::move(i));
53 21 : }
|