DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::ipm::ZmqContext Class Reference

#include <ZmqContext.hpp>

Public Member Functions

zmq::context_t & GetContext ()
 
void set_context_threads (int nthreads)
 
void set_context_maxsockets (int max_sockets)
 

Static Public Member Functions

static ZmqContextinstance ()
 

Private Member Functions

 ZmqContext ()
 
 ~ZmqContext ()
 
 ZmqContext (ZmqContext const &)=delete
 
 ZmqContext (ZmqContext &&)=delete
 
ZmqContextoperator= (ZmqContext const &)=delete
 
ZmqContextoperator= (ZmqContext &&)=delete
 

Private Attributes

zmq::context_t m_context
 

Static Private Attributes

static constexpr int s_minimum_sockets = 16636
 

Detailed Description

Definition at line 109 of file ZmqContext.hpp.

Constructor & Destructor Documentation

◆ ZmqContext() [1/3]

dunedaq::ipm::ZmqContext::ZmqContext ( )
inlineprivate

Definition at line 132 of file ZmqContext.hpp.

133 {
134 auto threads_c = getenv("IPM_ZMQ_IO_THREADS");
135 if (threads_c != nullptr) {
136 auto threads = std::atoi(threads_c); // NOLINT If a conversion error occurs, we discard the result
137 if (threads > 1) {
138 set_context_threads(threads);
139 }
140 }
141
142 bool sockets_set = false;
143 auto sockets_c = getenv("IPM_ZMQ_MAX_SOCKETS");
144 if (sockets_c != nullptr) {
145 auto sockets = std::atoi(sockets_c); // NOLINT If a conversion error occurs, we discard the result
146 if (sockets > s_minimum_sockets) {
147 set_context_maxsockets(sockets);
148 sockets_set = true;
149 }
150 }
151 if (!sockets_set) {
153 }
154 }
void set_context_threads(int nthreads)
void set_context_maxsockets(int max_sockets)
static constexpr int s_minimum_sockets

◆ ~ZmqContext()

dunedaq::ipm::ZmqContext::~ZmqContext ( )
inlineprivate

Definition at line 155 of file ZmqContext.hpp.

155 {
156 TLOG_DEBUG(TLVL_ZMQCONTEXT) << "Closing ZMQ Context";
157 m_context.close();
158 TLOG_DEBUG(TLVL_ZMQCONTEXT) << "ZMQ Context closed";
159 }
@ TLVL_ZMQCONTEXT
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112

◆ ZmqContext() [2/3]

dunedaq::ipm::ZmqContext::ZmqContext ( ZmqContext const & )
privatedelete

◆ ZmqContext() [3/3]

dunedaq::ipm::ZmqContext::ZmqContext ( ZmqContext && )
privatedelete

Member Function Documentation

◆ GetContext()

zmq::context_t & dunedaq::ipm::ZmqContext::GetContext ( )
inline

Definition at line 118 of file ZmqContext.hpp.

118{ return m_context; }

◆ instance()

static ZmqContext & dunedaq::ipm::ZmqContext::instance ( )
inlinestatic

Definition at line 112 of file ZmqContext.hpp.

113 {
114 static ZmqContext s_ctx;
115 return s_ctx;
116 }

◆ operator=() [1/2]

ZmqContext & dunedaq::ipm::ZmqContext::operator= ( ZmqContext && )
privatedelete

◆ operator=() [2/2]

ZmqContext & dunedaq::ipm::ZmqContext::operator= ( ZmqContext const & )
privatedelete

◆ set_context_maxsockets()

void dunedaq::ipm::ZmqContext::set_context_maxsockets ( int max_sockets)
inline

Definition at line 125 of file ZmqContext.hpp.

126 {
127 TLOG_DEBUG(TLVL_ZMQCONTEXT) << "Setting ZMQ Context max sockets to " << max_sockets;
128 m_context.set(zmq::ctxopt::max_sockets, max_sockets);
129 }

◆ set_context_threads()

void dunedaq::ipm::ZmqContext::set_context_threads ( int nthreads)
inline

Definition at line 120 of file ZmqContext.hpp.

121 {
122 TLOG_DEBUG(TLVL_ZMQCONTEXT) << "Setting ZMQ Context IO thread count to " << nthreads;
123 m_context.set(zmq::ctxopt::io_threads, nthreads);
124 }

Member Data Documentation

◆ m_context

zmq::context_t dunedaq::ipm::ZmqContext::m_context
private

Definition at line 160 of file ZmqContext.hpp.

◆ s_minimum_sockets

int dunedaq::ipm::ZmqContext::s_minimum_sockets = 16636
staticconstexprprivate

Definition at line 161 of file ZmqContext.hpp.


The documentation for this class was generated from the following file: