10#include <framework/logging/Logger.h> 
   45    template<
class AZMQMessage>
 
   46    static void send(std::unique_ptr<zmq::socket_t>& socket, AZMQMessage message);
 
   60    static unsigned int poll(
const std::vector<zmq::socket_t*>& socketList, 
int timeout);
 
   78    template<
int AZMQType>
 
   79    std::unique_ptr<zmq::socket_t> 
createSocket(
const std::string& socketAddress, 
bool bind);
 
   90    template<
int AZMQType>
 
   91    std::unique_ptr<zmq::socket_t> 
createSocket(
const std::string& socketAddress);
 
 
  104  template<
int AZMQType>
 
  115      auto socket = std::make_unique<zmq::socket_t>(*
m_context, AZMQType);
 
  117      if (AZMQType == ZMQ_DEALER) {
 
  119        socket->set(zmq::sockopt::routing_id, identity);
 
  124      socket->set(zmq::sockopt::linger, 0);
 
  126        socket->bind(socketAddress.c_str());
 
  128        socket->connect(socketAddress.c_str());
 
  132      std::this_thread::sleep_for(std::chrono::milliseconds(100));
 
  135    } 
catch (zmq::error_t& error) {
 
  136      B2FATAL(
"Creating the ZMQ socket for address " << socketAddress << 
" failed because of: " << error.what());
 
 
  140  template<
int AZMQType>
 
  145    if (socketAddress.find(
"*") != std::string::npos) {
 
 
  152  template<
class AZMQMessage>
 
  155    AZMQMessage::element_type::toSocket(std::move(message), socket);
 
 
A helper class for creating ZMQ sockets keeping track of the ZMQ context and terminating it if needed...
void initialize()
Initialize the parent by creating the context.
static unsigned int poll(const std::vector< zmq::socket_t * > &socketList, int timeout)
Poll function.
void terminate()
Terminate the parent manually (before calling its destructor). You probably do not need to do this.
static std::string createIdentity(unsigned int pid=0)
Create a unique ZMQ identity in the form <hostname>_<pid> (if pid is 0, use the current processes PID...
std::unique_ptr< zmq::context_t > m_context
ZMQ context.
~ZMQParent()
Destroy the parent by terminating the ZMQ context.
void reset()
Expert function: Reset the parent without context closing. ATTENTION: which will not clean up properl...
static void send(std::unique_ptr< zmq::socket_t > &socket, AZMQMessage message)
Send a given message over the given created socket. You need to move in the message for zero-copy.
std::unique_ptr< zmq::socket_t > createSocket(const std::string &socketAddress, bool bind)
Create a socket of the given type with the given address and bind or not bind it.
Abstract base class for different kinds of events.