Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ZeroMQPoller.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * RA, Roel Aaij, NIKHEF
5 * PB, Patrick Bos, Netherlands eScience Center, p.bos@esciencecenter.nl
6 *
7 * Copyright (c) 2021, CERN
8 *
9 * Redistribution and use in source and binary forms,
10 * with or without modification, are permitted according to the terms
11 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
12 */
13
14#ifndef ZEROMQPOLLER_H
15#define ZEROMQPOLLER_H 1
16
19#include <zmq.hpp>
20
21#include <vector>
22#include <deque>
23#include <exception>
24#include <unordered_map>
25
27public:
28 using entry_t = std::tuple<size_t, zmq::event_flags, const zmq::socket_t *>;
29 // The key is what zmq::socket_t stores inside, and what goes into
30 // pollitem_t through zmq::socket_t's conversion to void* operator
31 using sockets_t = std::unordered_map<void *, entry_t>;
32
33 using fd_entry_t = std::tuple<size_t, zmq::event_flags>;
34 using fds_t = std::unordered_map<int, fd_entry_t>;
35
36 using free_t = std::deque<int>;
37
38 ZeroMQPoller() = default;
39
40 std::vector<std::pair<size_t, zmq::event_flags>> poll(int timeo = -1);
41 std::vector<std::pair<size_t, zmq::event_flags>> ppoll(int timeo, const sigset_t *sigmask);
42
43 size_t size() const;
44
45 size_t register_socket(zmq::socket_t &socket, zmq::event_flags type);
46 size_t register_socket(int fd, zmq::event_flags type);
47
48 size_t unregister_socket(zmq::socket_t &socket);
49 size_t unregister_socket(int fd);
50
51private:
52 // Vector of (socket, flags)
53 std::vector<zmq::pollitem_t> m_items;
56
57 // free slots in items
59};
60
61#endif // ZEROMQPOLLER_H
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
Wrapper class for polling ZeroMQ sockets.
std::vector< zmq::pollitem_t > m_items
size_t register_socket(zmq::socket_t &socket, zmq::event_flags type)
Register socket to poll.
std::tuple< size_t, zmq::event_flags > fd_entry_t
std::tuple< size_t, zmq::event_flags, const zmq::socket_t * > entry_t
size_t size() const
sockets_t m_sockets
std::deque< int > free_t
std::vector< std::pair< size_t, zmq::event_flags > > ppoll(int timeo, const sigset_t *sigmask)
Poll the sockets with ppoll.
std::unordered_map< int, fd_entry_t > fds_t
size_t unregister_socket(zmq::socket_t &socket)
Unregister socket from poller.
std::unordered_map< void *, entry_t > sockets_t
std::vector< std::pair< size_t, zmq::event_flags > > poll(int timeo=-1)
Poll the sockets.
ZeroMQPoller()=default