pollset.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #ifndef __ZMQ_POLLSET_HPP_INCLUDED__
4 #define __ZMQ_POLLSET_HPP_INCLUDED__
5 
6 // poller.hpp decides which polling mechanism to use.
7 #include "poller.hpp"
8 #if defined ZMQ_IOTHREAD_POLLER_USE_POLLSET
9 
10 #include <sys/poll.h>
11 #include <sys/pollset.h>
12 #include <vector>
13 
14 #include "ctx.hpp"
15 #include "fd.hpp"
16 #include "thread.hpp"
17 #include "poller_base.hpp"
18 
19 namespace zmq
20 {
21 struct i_poll_events;
22 
23 // This class implements socket polling mechanism using the AIX-specific
24 // pollset mechanism.
25 
26 class pollset_t ZMQ_FINAL : public poller_base_t
27 {
28  public:
29  typedef void *handle_t;
30 
31  pollset_t (const thread_ctx_t &ctx_);
32  ~pollset_t () ZMQ_FINAL;
33 
34  // "poller" concept.
35  handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_);
36  void rm_fd (handle_t handle_);
37  void set_pollin (handle_t handle_);
38  void reset_pollin (handle_t handle_);
39  void set_pollout (handle_t handle_);
40  void reset_pollout (handle_t handle_);
41  void start ();
42  void stop ();
43 
44  static int max_fds ();
45 
46  private:
47  // Main worker thread routine.
48  static void worker_routine (void *arg_);
49 
50  // Main event loop.
51  void loop () ZMQ_FINAL;
52 
53  // Reference to ZMQ context.
54  const thread_ctx_t &ctx;
55 
56  // Main pollset file descriptor
57  ::pollset_t pollset_fd;
58 
59  struct poll_entry_t
60  {
61  fd_t fd;
62  bool flag_pollin;
63  bool flag_pollout;
64  zmq::i_poll_events *events;
65  };
66 
67  // List of retired event sources.
68  typedef std::vector<poll_entry_t *> retired_t;
69  retired_t retired;
70 
71  // This table stores data for registered descriptors.
72  typedef std::vector<poll_entry_t *> fd_table_t;
73  fd_table_t fd_table;
74 
75  // If true, thread is in the process of shutting down.
76  bool stopping;
77 
78  // Handle of the physical thread doing the I/O work.
79  thread_t worker;
80 
82 };
83 
84 typedef pollset_t poller_t;
85 }
86 
87 #endif
88 
89 #endif
benchmarks.python.py_benchmark.const
const
Definition: py_benchmark.py:14
zmq::i_poll_events
Definition: i_poll_events.hpp:13
ctx.hpp
zmq
Definition: zmq.hpp:229
poller.hpp
start
GLuint start
Definition: glcorearb.h:2858
ZMQ_NON_COPYABLE_NOR_MOVABLE
#define ZMQ_NON_COPYABLE_NOR_MOVABLE(classname)
Definition: macros.hpp:58
worker
void worker(int num)
Definition: test_multithread.cpp:83
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:57