libzmq  master
ZeroMQ C++ Core Engine (LIBZMQ)
command.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
3 
4  This file is part of libzmq, the ZeroMQ core engine in C++.
5 
6  libzmq is free software; you can redistribute it and/or modify it under
7  the terms of the GNU Lesser General Public License (LGPL) as published
8  by the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  As a special exception, the Contributors give you permission to link
12  this library with independent modules to produce an executable,
13  regardless of the license terms of these independent modules, and to
14  copy and distribute the resulting executable under terms of your choice,
15  provided that you also meet, for each linked independent module, the
16  terms and conditions of the license of that module. An independent
17  module is a module which is not derived from or based on this library.
18  If you modify this library, you must extend this exception to your
19  version of the library.
20 
21  libzmq is distributed in the hope that it will be useful, but WITHOUT
22  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
24  License for more details.
25 
26  You should have received a copy of the GNU Lesser General Public License
27  along with this program. If not, see <http://www.gnu.org/licenses/>.
28 */
29 
30 #ifndef __ZMQ_COMMAND_HPP_INCLUDED__
31 #define __ZMQ_COMMAND_HPP_INCLUDED__
32 
33 #include "stdint.hpp"
34 
35 namespace zmq
36 {
37 
38  class object_t;
39  class own_t;
40  struct i_engine;
41  class pipe_t;
42  class socket_base_t;
43 
44  // This structure defines the commands that can be sent between threads.
45 
46 #ifdef _MSC_VER
47  __declspec(align(64)) struct command_t
48 #else
49  struct command_t
50 #endif
51  {
52  // Object to process the command.
54 
55  enum type_t
56  {
59  own,
74  } type;
75 
76  union args_t
77  {
78 
79  // Sent to I/O thread to let it know that it should
80  // terminate itself.
81  struct {
82  } stop;
83 
84  // Sent to I/O object to make it register with its I/O thread.
85  struct {
86  } plug;
87 
88  // Sent to socket to let it know about the newly created object.
89  struct {
91  } own;
92 
93  // Attach the engine to the session. If engine is NULL, it informs
94  // session that the connection have failed.
95  struct {
96  struct i_engine *engine;
97  } attach;
98 
99  // Sent from session to socket to establish pipe(s) between them.
100  // Caller have used inc_seqnum beforehand sending the command.
101  struct {
103  } bind;
104 
105  // Sent by pipe writer to inform dormant pipe reader that there
106  // are messages in the pipe.
107  struct {
108  } activate_read;
109 
110  // Sent by pipe reader to inform pipe writer about how many
111  // messages it has read so far.
112  struct {
113  uint64_t msgs_read;
114  } activate_write;
115 
116  // Sent by pipe reader to writer after creating a new inpipe.
117  // The parameter is actually of type pipe_t::upipe_t, however,
118  // its definition is private so we'll have to do with void*.
119  struct {
120  void *pipe;
121  } hiccup;
122 
123  // Sent by pipe reader to pipe writer to ask it to terminate
124  // its end of the pipe.
125  struct {
126  } pipe_term;
127 
128  // Pipe writer acknowledges pipe_term command.
129  struct {
130  } pipe_term_ack;
131 
132  // Sent by I/O object ot the socket to request the shutdown of
133  // the I/O object.
134  struct {
137 
138  // Sent by socket to I/O object to start its shutdown.
139  struct {
140  int linger;
141  } term;
142 
143  // Sent by I/O object to the socket to acknowledge it has
144  // shut down.
145  struct {
146  } term_ack;
147 
148  // Transfers the ownership of the closed socket
149  // to the reaper thread.
150  struct {
152  } reap;
153 
154  // Closed socket notifies the reaper that it's already deallocated.
155  struct {
156  } reaped;
157 
158  // Sent by reaper thread to the term thread when all the sockets
159  // are successfully deallocated.
160  struct {
161  } done;
162 
163  } args;
164 #ifdef _MSC_VER
165  };
166 #else
167  } __attribute__((aligned(64)));
168 #endif
169 }
170 
171 #endif
struct zmq::command_t::args_t::@12 term
struct zmq::command_t::args_t::@14 reap
struct zmq::command_t::args_t::@3 own
struct zmq::command_t::args_t::@16 done
struct zmq::command_t::args_t::@9 pipe_term
union zmq::command_t::args_t args
zmq::socket_base_t * socket
Definition: command.hpp:151
struct zmq::command_t::args_t::@5 bind
struct zmq::command_t::args_t::@7 activate_write
struct zmq::command_t::args_t::@8 hiccup
struct zmq::command_t::args_t::@1 stop
zmq::object_t * destination
Definition: command.hpp:53
struct zmq::command_t::args_t::@11 term_req
zmq::own_t * object
Definition: command.hpp:90
enum zmq::command_t::type_t type
zmq::pipe_t * pipe
Definition: command.hpp:102
struct i_engine * engine
Definition: command.hpp:96
struct zmq::command_t::args_t::@6 activate_read
struct zmq::command_t::args_t::@13 term_ack
struct zmq::command_t::args_t::@10 pipe_term_ack
struct zmq::command_t __attribute__((aligned(64)))
struct zmq::command_t::args_t::@15 reaped
Definition: address.hpp:35
struct zmq::command_t::args_t::@4 attach
struct zmq::command_t::args_t::@2 plug