dist.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #ifndef __ZMQ_DIST_HPP_INCLUDED__
4 #define __ZMQ_DIST_HPP_INCLUDED__
5 
6 #include <vector>
7 
8 #include "array.hpp"
9 #include "macros.hpp"
10 
11 namespace zmq
12 {
13 class pipe_t;
14 class msg_t;
15 
16 // Class manages a set of outbound pipes. It sends each messages to
17 // each of them.
18 class dist_t
19 {
20  public:
21  dist_t ();
22  ~dist_t ();
23 
24  // Adds the pipe to the distributor object.
25  void attach (zmq::pipe_t *pipe_);
26 
27  // Checks if this pipe is present in the distributor.
28  bool has_pipe (zmq::pipe_t *pipe_);
29 
30  // Activates pipe that have previously reached high watermark.
31  void activated (zmq::pipe_t *pipe_);
32 
33  // Mark the pipe as matching. Subsequent call to send_to_matching
34  // will send message also to this pipe.
35  void match (zmq::pipe_t *pipe_);
36 
37  // Marks all pipes that are not matched as matched and vice-versa.
38  void reverse_match ();
39 
40  // Mark all pipes as non-matching.
41  void unmatch ();
42 
43  // Removes the pipe from the distributor object.
44  void pipe_terminated (zmq::pipe_t *pipe_);
45 
46  // Send the message to the matching outbound pipes.
47  int send_to_matching (zmq::msg_t *msg_);
48 
49  // Send the message to all the outbound pipes.
50  int send_to_all (zmq::msg_t *msg_);
51 
52  static bool has_out ();
53 
54  // check HWM of all pipes matching
55  bool check_hwm ();
56 
57  private:
58  // Write the message to the pipe. Make the pipe inactive if writing
59  // fails. In such a case false is returned.
60  bool write (zmq::pipe_t *pipe_, zmq::msg_t *msg_);
61 
62  // Put the message to all active pipes.
63  void distribute (zmq::msg_t *msg_);
64 
65  // List of outbound pipes.
68 
69  // Number of all the pipes to send the next message to.
71 
72  // Number of active pipes. All the active pipes are located at the
73  // beginning of the pipes array. These are the pipes the messages
74  // can be sent to at the moment.
76 
77  // Number of pipes eligible for sending messages to. This includes all
78  // the active pipes plus all the pipes that we can in theory send
79  // messages to (the HWM is not yet reached), but sending a message
80  // to them would result in partial message being delivered, ie. message
81  // with initial parts missing.
83 
84  // True if last we are in the middle of a multipart message.
85  bool _more;
86 
88 };
89 }
90 
91 #endif
zmq::dist_t::activated
void activated(zmq::pipe_t *pipe_)
Definition: dist.cpp:105
zmq::dist_t::send_to_matching
int send_to_matching(zmq::msg_t *msg_)
Definition: dist.cpp:127
zmq::dist_t::attach
void attach(zmq::pipe_t *pipe_)
Definition: dist.cpp:20
array.hpp
zmq::dist_t::_eligible
pipes_t::size_type _eligible
Definition: dist.hpp:82
zmq
Definition: zmq.hpp:229
macros.hpp
ZMQ_NON_COPYABLE_NOR_MOVABLE
#define ZMQ_NON_COPYABLE_NOR_MOVABLE(classname)
Definition: macros.hpp:58
zmq::dist_t::send_to_all
int send_to_all(zmq::msg_t *msg_)
Definition: dist.cpp:121
zmq::dist_t::write
bool write(zmq::pipe_t *pipe_, zmq::msg_t *msg_)
Definition: dist.cpp:196
zmq::dist_t::_matching
pipes_t::size_type _matching
Definition: dist.hpp:70
zmq::dist_t::dist_t
dist_t()
Definition: dist.cpp:10
zmq::dist_t::has_out
static bool has_out()
Definition: dist.cpp:191
zmq::dist_t::_active
pipes_t::size_type _active
Definition: dist.hpp:75
zmq::dist_t::pipes_t
array_t< zmq::pipe_t, 2 > pipes_t
Definition: dist.hpp:66
zmq::dist_t::_pipes
pipes_t _pipes
Definition: dist.hpp:67
zmq::dist_t::unmatch
void unmatch()
Definition: dist.cpp:80
zmq::dist_t::check_hwm
bool check_hwm()
Definition: dist.cpp:212
zmq::array_t< zmq::pipe_t, 2 >::size_type
std::vector< zmq::pipe_t * >::size_type size_type
Definition: array.hpp:52
zmq::dist_t::reverse_match
void reverse_match()
Definition: dist.cpp:64
zmq::dist_t
Definition: dist.hpp:18
zmq::dist_t::match
void match(zmq::pipe_t *pipe_)
Definition: dist.cpp:49
zmq::dist_t::pipe_terminated
void pipe_terminated(zmq::pipe_t *pipe_)
Definition: dist.cpp:85
zmq::dist_t::~dist_t
~dist_t()
Definition: dist.cpp:15
zmq::array_t< zmq::pipe_t, 2 >
zmq::dist_t::distribute
void distribute(zmq::msg_t *msg_)
Definition: dist.cpp:144
zmq::msg_t
Definition: msg.hpp:33
zmq::dist_t::_more
bool _more
Definition: dist.hpp:85
zmq::dist_t::has_pipe
bool has_pipe(zmq::pipe_t *pipe_)
Definition: dist.cpp:37


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