libzmq
src
mailbox.hpp
Go to the documentation of this file.
1
/* SPDX-License-Identifier: MPL-2.0 */
2
3
#ifndef __ZMQ_MAILBOX_HPP_INCLUDED__
4
#define __ZMQ_MAILBOX_HPP_INCLUDED__
5
6
#include <stddef.h>
7
8
#include "
signaler.hpp
"
9
#include "
fd.hpp
"
10
#include "
config.hpp
"
11
#include "
command.hpp
"
12
#include "
ypipe.hpp
"
13
#include "
mutex.hpp
"
14
#include "
i_mailbox.hpp
"
15
16
namespace
zmq
17
{
18
class
mailbox_t
ZMQ_FINAL
:
public
i_mailbox
19
{
20
public
:
21
mailbox_t ();
22
~mailbox_t ();
23
24
fd_t
get_fd
()
const
;
25
void
send
(
const
command_t &cmd_);
26
int
recv (command_t *cmd_,
int
timeout_);
27
28
bool
valid ()
const
;
29
30
#ifdef HAVE_FORK
31
// close the file descriptors in the signaller. This is used in a forked
32
// child process to close the file descriptors so that they do not interfere
33
// with the context in the parent process.
34
void
forked ()
ZMQ_FINAL
35
{
36
_signaler.forked ();
37
}
38
#endif
39
40
private
:
41
// The pipe to store actual commands.
42
typedef
ypipe_t<command_t, command_pipe_granularity>
cpipe_t
;
43
cpipe_t
_cpipe
;
44
45
// Signaler to pass signals from writer thread to reader thread.
46
signaler_t
_signaler
;
47
48
// There's only one thread receiving from the mailbox, but there
49
// is arbitrary number of threads sending. Given that ypipe requires
50
// synchronised access on both of its endpoints, we have to synchronise
51
// the sending side.
52
mutex_t
_sync
;
53
54
// True if the underlying pipe is active, ie. when we are allowed to
55
// read commands from it.
56
bool
_active
;
57
58
ZMQ_NON_COPYABLE_NOR_MOVABLE
(mailbox_t)
59
};
60
}
61
62
#endif
zmq::ZMQ_FINAL::_active
bool _active
Definition:
mailbox.hpp:56
config.hpp
ypipe.hpp
zmq::ZMQ_FINAL::cpipe_t
ypipe_t< command_t, command_pipe_granularity > cpipe_t
Definition:
mailbox.hpp:42
send
void send(fd_t fd_, const char(&data_)[N])
Definition:
test_security_curve.cpp:209
get_fd
SETUP_TEARDOWN_TESTCONTEXT fd_t get_fd(void *socket_)
Definition:
test_poller.cpp:17
command.hpp
zmq
Definition:
zmq.hpp:229
i_mailbox.hpp
ZMQ_NON_COPYABLE_NOR_MOVABLE
#define ZMQ_NON_COPYABLE_NOR_MOVABLE(classname)
Definition:
macros.hpp:58
fd.hpp
zmq::mutex_t
Definition:
mutex.hpp:82
zmq::ZMQ_FINAL::_cpipe
cpipe_t _cpipe
Definition:
mailbox.hpp:43
zmq::signaler_t
Definition:
signaler.hpp:20
signaler.hpp
zmq::ZMQ_FINAL::_sync
mutex_t _sync
Definition:
mailbox.hpp:52
fd_t
zmq_fd_t fd_t
Definition:
libzmq/tests/testutil.hpp:98
zmq::ZMQ_FINAL::_signaler
signaler_t _signaler
Definition:
mailbox.hpp:46
ZMQ_FINAL
Definition:
unittest_ip_resolver.cpp:26
mutex.hpp
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:55