39 std::vector<std::pair<size_t, zmq::event_flags>>
r;
41 throw std::runtime_error(
"No sockets registered");
46 n = zmq::poll(
m_items, std::chrono::milliseconds{timeo});
50 }
catch (
const zmq::error_t &
e) {
51 std::cerr <<
"in ZeroMQPoller::poll on PID " << getpid() <<
": " <<
e.what() << std::endl;
52 if (
e.num() != EINTR) {
58 for (
size_t i = 0; i <
m_items.size(); ++i) {
61 zmq::event_flags flags = zmq::event_flags::none;
67 const zmq::socket_t *s;
70 if (
m_items[i].revents &
short(flags)) {
71 r.emplace_back(
index, flags);
91std::vector<std::pair<size_t, zmq::event_flags>>
ZeroMQPoller::ppoll(
int timeo,
const sigset_t *sigmask)
94 throw std::runtime_error(
"No sockets registered");
97 std::vector<std::pair<size_t, zmq::event_flags>>
r;
105 zmq::event_flags flags = zmq::event_flags::none;
106 if (m_item.socket ==
nullptr) {
111 const zmq::socket_t *s;
114 if (m_item.revents &
short(flags)) {
115 r.emplace_back(
index, flags);
138 zmq::socket_t *s = &
socket;
141 return std::get<0>(it->second);
167 auto it =
m_fds.find(fd);
168 if (it !=
m_fds.end()) {
169 return std::get<0>(it->second);
176 m_items.push_back({
nullptr, fd,
static_cast<short>(
type), 0});
194 throw std::out_of_range(
"Socket is not registered");
201 return &
socket == std::get<2>(entry.second);
203 auto index = std::get<0>(it->second);
205 void *it_first = it->first;
210 [&it_first](
const zmq::pollitem_t &item) {
return it_first == item.socket; });
227 if (!
m_fds.count(fd)) {
228 throw std::out_of_range(
"fileno is not registered");
231 auto it =
m_fds.find(fd);
232 auto index = std::get<0>(it->second);
234 int it_first = it->first;
239 [&it_first](
const zmq::pollitem_t &item) {
return it_first == item.fd; });
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
std::vector< zmq::pollitem_t > m_items
size_t register_socket(zmq::socket_t &socket, zmq::event_flags type)
Register socket to poll.
std::vector< std::pair< size_t, zmq::event_flags > > ppoll(int timeo, const sigset_t *sigmask)
Poll the sockets with ppoll.
size_t unregister_socket(zmq::socket_t &socket)
Unregister socket from poller.
std::vector< std::pair< size_t, zmq::event_flags > > poll(int timeo=-1)
Poll the sockets.
int ppoll(zmq_pollitem_t *items_, size_t nitems_, long timeout_, const sigset_t *sigmask_)
Wrapper around zmq_ppoll This function can throw, so wrap in try-catch!