devpoll.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #ifndef __ZMQ_DEVPOLL_HPP_INCLUDED__
4 #define __ZMQ_DEVPOLL_HPP_INCLUDED__
5 
6 // poller.hpp decides which polling mechanism to use.
7 #include "poller.hpp"
8 #if defined ZMQ_IOTHREAD_POLLER_USE_DEVPOLL
9 
10 #include <vector>
11 
12 #include "ctx.hpp"
13 #include "fd.hpp"
14 #include "thread.hpp"
15 #include "poller_base.hpp"
16 
17 namespace zmq
18 {
19 struct i_poll_events;
20 
21 // Implements socket polling mechanism using the "/dev/poll" interface.
22 
23 class devpoll_t ZMQ_FINAL : public worker_poller_base_t
24 {
25  public:
26  typedef fd_t handle_t;
27 
28  devpoll_t (const thread_ctx_t &ctx_);
29  ~devpoll_t () ZMQ_FINAL;
30 
31  // "poller" concept.
32  handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_);
33  void rm_fd (handle_t handle_);
34  void set_pollin (handle_t handle_);
35  void reset_pollin (handle_t handle_);
36  void set_pollout (handle_t handle_);
37  void reset_pollout (handle_t handle_);
38  void stop ();
39 
40  static int max_fds ();
41 
42  private:
43  // Main event loop.
44  void loop () ZMQ_FINAL;
45 
46  // File descriptor referring to "/dev/poll" pseudo-device.
47  fd_t devpoll_fd;
48 
49  struct fd_entry_t
50  {
51  short events;
52  zmq::i_poll_events *reactor;
53  bool valid;
54  bool accepted;
55  };
56 
57  typedef std::vector<fd_entry_t> fd_table_t;
58  fd_table_t fd_table;
59 
60  typedef std::vector<fd_t> pending_list_t;
61  pending_list_t pending_list;
62 
63  // Pollset manipulation function.
64  void devpoll_ctl (fd_t fd_, short events_);
65 
67 };
68 
69 typedef devpoll_t poller_t;
70 }
71 
72 #endif
73 
74 #endif
zmq::i_poll_events
Definition: i_poll_events.hpp:13
ctx.hpp
zmq
Definition: zmq.hpp:229
poller.hpp
ZMQ_NON_COPYABLE_NOR_MOVABLE
#define ZMQ_NON_COPYABLE_NOR_MOVABLE(classname)
Definition: macros.hpp:58
thread.hpp
fd.hpp
fd_t
zmq_fd_t fd_t
Definition: libzmq/tests/testutil.hpp:98
ZMQ_FINAL
Definition: unittest_ip_resolver.cpp:26
poller_base.hpp


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:50