8 #include <framework/pcore/zmq/utils/ZMQParent.h>
14 ZMQParent::~ZMQParent()
19 void ZMQParent::terminate()
27 void ZMQParent::reset()
32 std::string ZMQParent::createIdentity(
unsigned int pid)
34 char hostname[HOST_NAME_MAX];
35 gethostname(hostname, HOST_NAME_MAX);
41 return std::string(hostname) +
"_" + std::to_string(pid);
44 void ZMQParent::initialize()
49 m_context = std::make_unique<zmq::context_t>(1);
52 #if defined(__GNUC__) && !defined(__clang__)
53 #pragma GCC diagnostic push
54 #pragma GCC diagnostic ignored "-Wstack-usage="
56 unsigned int ZMQParent::poll(
const std::vector<zmq::socket_t*>& socketList,
int timeout)
58 B2ASSERT(
"Only allow to poll on maximal 8 sockets at the same time!", socketList.size() <= 8);
59 std::bitset<8> return_bitmask;
60 zmq::pollitem_t items[socketList.size()];
62 for (
unsigned int i = 0; i < socketList.size(); i++) {
63 items[i].socket =
static_cast<void*
>(*socketList[i]);
64 items[i].events = ZMQ_POLLIN;
69 zmq::poll(items, socketList.size(), timeout);
71 for (
unsigned int i = 0; i < socketList.size(); i++) {
72 return_bitmask[i] =
static_cast<bool>(items[i].revents & ZMQ_POLLIN);
74 return return_bitmask.to_ulong();
75 }
catch (zmq::error_t& error) {
76 if (error.num() == EINTR) {
84 #if defined(__GNUC__) && !defined(__clang__)
85 #pragma GCC diagnostic pop
Abstract base class for different kinds of events.