signaler.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #ifndef __ZMQ_SIGNALER_HPP_INCLUDED__
4 #define __ZMQ_SIGNALER_HPP_INCLUDED__
5 
6 #ifdef HAVE_FORK
7 #include <unistd.h>
8 #endif
9 
10 #include "fd.hpp"
11 #include "macros.hpp"
12 
13 namespace zmq
14 {
15 // This is a cross-platform equivalent to signal_fd. However, as opposed
16 // to signal_fd there can be at most one signal in the signaler at any
17 // given moment. Attempt to send a signal before receiving the previous
18 // one will result in undefined behaviour.
19 
21 {
22  public:
23  signaler_t ();
24  ~signaler_t ();
25 
26  // Returns the socket/file descriptor
27  // May return retired_fd if the signaler could not be initialized.
28  fd_t get_fd () const;
29  void send ();
30  int wait (int timeout_) const;
31  void recv ();
32  int recv_failable ();
33 
34  bool valid () const;
35 
36 #ifdef HAVE_FORK
37  // close the file descriptors in a forked child process so that they
38  // do not interfere with the context in the parent process.
39  void forked ();
40 #endif
41 
42  private:
43  // Underlying write & read file descriptor
44  // Will be -1 if an error occurred during initialization, e.g. we
45  // exceeded the number of available handles
48 
49 #ifdef HAVE_FORK
50  // the process that created this context. Used to detect forking.
51  pid_t pid;
52  // idempotent close of file descriptors that is safe to use by destructor
53  // and forked().
54  void close_internal ();
55 #endif
56 
58 };
59 }
60 
61 #endif
zmq::signaler_t::signaler_t
signaler_t()
Definition: signaler.cpp:91
zmq::fd_t
int fd_t
Definition: zmq.hpp:287
zmq
Definition: zmq.hpp:229
macros.hpp
zmq::signaler_t::send
void send()
Definition: signaler.cpp:146
ZMQ_NON_COPYABLE_NOR_MOVABLE
#define ZMQ_NON_COPYABLE_NOR_MOVABLE(classname)
Definition: macros.hpp:58
zmq::signaler_t::_r
fd_t _r
Definition: signaler.hpp:47
fd.hpp
zmq::signaler_t::_w
fd_t _w
Definition: signaler.hpp:46
zmq::signaler_t::get_fd
fd_t get_fd() const
Definition: signaler.cpp:141
zmq::signaler_t
Definition: signaler.hpp:20
zmq::signaler_t::~signaler_t
~signaler_t()
Definition: signaler.cpp:105
zmq::signaler_t::recv
void recv()
Definition: signaler.cpp:275
zmq::signaler_t::recv_failable
int recv_failable()
Definition: signaler.cpp:311
zmq::signaler_t::valid
bool valid() const
Definition: signaler.cpp:374
zmq::signaler_t::wait
int wait(int timeout_) const
Definition: signaler.cpp:203


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