DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Sender.cpp
Go to the documentation of this file.
1
9#include "ipm/Sender.hpp"
10#include "ipm/opmon/ipm.pb.h"
11
12#include <string>
13#include <utility>
14#include <vector>
15
16bool
17dunedaq::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 if (message_size == 0) {
24 return true;
25 }
26
27 if (!can_send()) {
28 throw KnownStateForbidsSend(ERS_HERE);
29 }
30
31 if (!message) {
32 throw NullPointerPassedToSend(ERS_HERE);
33 }
34
35 auto res = send_(message, message_size, timeout, metadata, no_tmoexcept_mode);
36
37 m_bytes += message_size;
38 ++m_messages;
39
40 return res;
41}
42
43void
45{
46
48
49 i.set_bytes(m_bytes.exchange(0));
50 i.set_messages(m_messages.exchange(0));
51
52 publish(std::move(i));
53}
#define ERS_HERE
std::chrono::milliseconds duration_t
Definition Sender.hpp:76
std::atomic< size_t > m_messages
Definition Sender.hpp:117
void generate_opmon_data() override
Definition Sender.cpp:44
std::atomic< size_t > m_bytes
Definition Sender.hpp:116
bool send(const void *message, message_size_t message_size, const duration_t &timeout, std::string const &metadata="", bool no_tmoexcept_mode=false)
Definition Sender.cpp:17
virtual bool send_(const void *message, message_size_t N, const duration_t &timeout, std::string const &metadata, bool no_tmoexcept_mode)=0
virtual bool can_send() const noexcept=0
void set_bytes(::uint64_t value)
Definition ipm.pb.h:446
void set_messages(::uint64_t value)
Definition ipm.pb.h:468