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 <vector>
14
15bool
16dunedaq::ipm::Sender::send(const void* message,
17 message_size_t message_size,
18 const duration_t& timeout,
19 std::string const& metadata,
20 bool no_tmoexcept_mode)
21{
22 if (message_size == 0) {
23 return true;
24 }
25
26 if (!can_send()) {
27 throw KnownStateForbidsSend(ERS_HERE);
28 }
29
30 if (!message) {
31 throw NullPointerPassedToSend(ERS_HERE);
32 }
33
34 auto res = send_(message, message_size, timeout, metadata, no_tmoexcept_mode);
35
36 m_bytes += message_size;
37 ++m_messages;
38
39 return res;
40}
41
42void
44{
45
47
48 i.set_bytes(m_bytes.exchange(0));
49 i.set_messages(m_messages.exchange(0));
50
51 publish(std::move(i));
52}
#define ERS_HERE
std::chrono::milliseconds duration_t
Definition Sender.hpp:73
std::atomic< size_t > m_messages
Definition Sender.hpp:115
void generate_opmon_data() override
Definition Sender.cpp:43
std::atomic< size_t > m_bytes
Definition Sender.hpp:114
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:16
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