epoll.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #ifndef __ZMQ_EPOLL_HPP_INCLUDED__
4 #define __ZMQ_EPOLL_HPP_INCLUDED__
5 
6 // poller.hpp decides which polling mechanism to use.
7 #include "poller.hpp"
8 #if defined ZMQ_IOTHREAD_POLLER_USE_EPOLL
9 
10 #include <vector>
11 
12 #if defined ZMQ_HAVE_WINDOWS
13 #include "../external/wepoll/wepoll.h"
14 #else
15 #include <sys/epoll.h>
16 #endif
17 
18 #include "ctx.hpp"
19 #include "fd.hpp"
20 #include "thread.hpp"
21 #include "poller_base.hpp"
22 #include "mutex.hpp"
23 
24 namespace zmq
25 {
26 struct i_poll_events;
27 
28 // This class implements socket polling mechanism using the Linux-specific
29 // epoll mechanism.
30 
31 class epoll_t ZMQ_FINAL : public worker_poller_base_t
32 {
33  public:
34  typedef void *handle_t;
35 
36  epoll_t (const thread_ctx_t &ctx_);
37  ~epoll_t () ZMQ_OVERRIDE;
38 
39  // "poller" concept.
40  handle_t add_fd (fd_t fd_, zmq::i_poll_events *events_);
41  void rm_fd (handle_t handle_);
42  void set_pollin (handle_t handle_);
43  void reset_pollin (handle_t handle_);
44  void set_pollout (handle_t handle_);
45  void reset_pollout (handle_t handle_);
46  void stop ();
47 
48  static int max_fds ();
49 
50  private:
51 #if defined ZMQ_HAVE_WINDOWS
52  typedef HANDLE epoll_fd_t;
53  static const epoll_fd_t epoll_retired_fd;
54 #else
55  typedef fd_t epoll_fd_t;
56  enum
57  {
58  epoll_retired_fd = retired_fd
59  };
60 #endif
61 
62  // Main event loop.
63  void loop () ZMQ_OVERRIDE;
64 
65  // Main epoll file descriptor
66  epoll_fd_t _epoll_fd;
67 
68  struct poll_entry_t
69  {
70  fd_t fd;
71  epoll_event ev;
72  zmq::i_poll_events *events;
73  };
74 
75  // List of retired event sources.
76  typedef std::vector<poll_entry_t *> retired_t;
77  retired_t _retired;
78 
80 };
81 
82 typedef epoll_t poller_t;
83 }
84 
85 #endif
86 
87 #endif
zmq::retired_fd
@ retired_fd
Definition: fd.hpp:32
zmq::i_poll_events
Definition: i_poll_events.hpp:13
ctx.hpp
zmq
Definition: zmq.hpp:229
ZMQ_OVERRIDE
#define ZMQ_OVERRIDE
Definition: zmq.hpp:91
poller.hpp
ZMQ_NON_COPYABLE_NOR_MOVABLE
#define ZMQ_NON_COPYABLE_NOR_MOVABLE(classname)
Definition: macros.hpp:58
thread.hpp
fd.hpp
epoll_event
Definition: wepoll.c:82
fd_t
zmq_fd_t fd_t
Definition: libzmq/tests/testutil.hpp:98
HANDLE
void * HANDLE
Definition: wepoll.c:70
ZMQ_FINAL
Definition: unittest_ip_resolver.cpp:26
mutex.hpp
poller_base.hpp


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