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
int type
Definition TGX11.cxx:121
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