2009-07-29 12:07:54 +02:00
|
|
|
/*
|
2016-01-28 15:07:31 +01:00
|
|
|
Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
|
2009-07-29 12:07:54 +02:00
|
|
|
|
2015-06-02 22:33:55 +02:00
|
|
|
This file is part of libzmq, the ZeroMQ core engine in C++.
|
2009-07-29 12:07:54 +02:00
|
|
|
|
2015-06-02 22:33:55 +02:00
|
|
|
libzmq is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
|
|
|
by the Free Software Foundation; either version 3 of the License, or
|
2009-07-29 12:07:54 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
2015-06-02 22:33:55 +02:00
|
|
|
As a special exception, the Contributors give you permission to link
|
|
|
|
this library with independent modules to produce an executable,
|
|
|
|
regardless of the license terms of these independent modules, and to
|
|
|
|
copy and distribute the resulting executable under terms of your choice,
|
|
|
|
provided that you also meet, for each linked independent module, the
|
|
|
|
terms and conditions of the license of that module. An independent
|
|
|
|
module is a module which is not derived from or based on this library.
|
|
|
|
If you modify this library, you must extend this exception to your
|
|
|
|
version of the library.
|
|
|
|
|
|
|
|
libzmq is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
2009-07-29 12:07:54 +02:00
|
|
|
|
2010-10-30 15:08:28 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2009-07-29 12:07:54 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-08-03 11:30:13 +02:00
|
|
|
#ifndef __ZMQ_COMMAND_HPP_INCLUDED__
|
|
|
|
#define __ZMQ_COMMAND_HPP_INCLUDED__
|
2009-07-29 12:07:54 +02:00
|
|
|
|
2017-09-19 01:14:10 +02:00
|
|
|
#include <string>
|
2009-07-29 12:07:54 +02:00
|
|
|
#include "stdint.hpp"
|
2019-01-31 17:23:42 +01:00
|
|
|
#include "endpoint.hpp"
|
2009-07-29 12:07:54 +02:00
|
|
|
|
2009-08-03 11:30:13 +02:00
|
|
|
namespace zmq
|
2009-07-29 12:07:54 +02:00
|
|
|
{
|
2011-11-09 15:22:20 +01:00
|
|
|
class object_t;
|
|
|
|
class own_t;
|
|
|
|
struct i_engine;
|
|
|
|
class pipe_t;
|
|
|
|
class socket_base_t;
|
2009-07-29 12:07:54 +02:00
|
|
|
|
|
|
|
// This structure defines the commands that can be sent between threads.
|
|
|
|
|
2015-01-13 23:47:00 +01:00
|
|
|
#ifdef _MSC_VER
|
2017-07-27 06:06:19 +02:00
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable : 4324) // C4324: alignment padding warnings
|
|
|
|
__declspec(align (64))
|
2015-01-13 23:47:00 +01:00
|
|
|
#endif
|
2017-07-27 06:06:19 +02:00
|
|
|
struct command_t
|
2018-02-01 11:46:09 +01:00
|
|
|
{
|
2009-07-29 12:07:54 +02:00
|
|
|
// Object to process the command.
|
2011-11-09 15:22:20 +01:00
|
|
|
zmq::object_t *destination;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-07-29 12:07:54 +02:00
|
|
|
enum type_t
|
|
|
|
{
|
|
|
|
stop,
|
2009-08-08 16:01:58 +02:00
|
|
|
plug,
|
|
|
|
own,
|
2009-08-20 11:32:23 +02:00
|
|
|
attach,
|
2009-07-29 12:07:54 +02:00
|
|
|
bind,
|
2011-05-22 17:26:53 +02:00
|
|
|
activate_read,
|
|
|
|
activate_write,
|
2011-05-30 10:07:34 +02:00
|
|
|
hiccup,
|
2009-08-28 16:51:46 +02:00
|
|
|
pipe_term,
|
|
|
|
pipe_term_ack,
|
2017-01-11 03:49:54 +01:00
|
|
|
pipe_hwm,
|
2009-08-08 16:01:58 +02:00
|
|
|
term_req,
|
|
|
|
term,
|
2011-02-09 15:32:15 +01:00
|
|
|
term_ack,
|
2017-09-19 01:14:10 +02:00
|
|
|
term_endpoint,
|
2011-02-09 15:32:15 +01:00
|
|
|
reap,
|
2011-02-09 22:23:21 +01:00
|
|
|
reaped,
|
2013-09-12 19:09:37 +02:00
|
|
|
inproc_connected,
|
2020-02-23 18:17:22 +01:00
|
|
|
conn_failed,
|
2019-01-31 17:23:42 +01:00
|
|
|
pipe_peer_stats,
|
|
|
|
pipe_stats_publish,
|
2011-02-09 15:32:15 +01:00
|
|
|
done
|
2009-07-29 12:07:54 +02:00
|
|
|
} type;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2015-01-13 15:16:27 +01:00
|
|
|
union args_t
|
|
|
|
{
|
2009-08-08 16:01:58 +02:00
|
|
|
// Sent to I/O thread to let it know that it should
|
|
|
|
// terminate itself.
|
2009-07-29 12:07:54 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
} stop;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-08-08 16:01:58 +02:00
|
|
|
// Sent to I/O object to make it register with its I/O thread.
|
2009-07-29 12:07:54 +02:00
|
|
|
struct
|
|
|
|
{
|
2009-08-08 16:01:58 +02:00
|
|
|
} plug;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-08-08 16:01:58 +02:00
|
|
|
// Sent to socket to let it know about the newly created object.
|
2009-07-29 12:07:54 +02:00
|
|
|
struct
|
|
|
|
{
|
2011-11-09 15:22:20 +01:00
|
|
|
zmq::own_t *object;
|
2009-08-08 16:01:58 +02:00
|
|
|
} own;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2010-09-17 12:58:20 +02:00
|
|
|
// Attach the engine to the session. If engine is NULL, it informs
|
|
|
|
// session that the connection have failed.
|
2009-08-20 11:32:23 +02:00
|
|
|
struct
|
|
|
|
{
|
2009-08-30 08:18:31 +02:00
|
|
|
struct i_engine *engine;
|
2009-08-20 11:32:23 +02:00
|
|
|
} attach;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-08-27 10:54:28 +02:00
|
|
|
// Sent from session to socket to establish pipe(s) between them.
|
2009-12-01 18:50:54 +01:00
|
|
|
// Caller have used inc_seqnum beforehand sending the command.
|
2009-07-29 12:07:54 +02:00
|
|
|
struct
|
|
|
|
{
|
2011-11-09 15:22:20 +01:00
|
|
|
zmq::pipe_t *pipe;
|
2009-08-08 16:01:58 +02:00
|
|
|
} bind;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-08-27 10:54:28 +02:00
|
|
|
// Sent by pipe writer to inform dormant pipe reader that there
|
|
|
|
// are messages in the pipe.
|
|
|
|
struct
|
|
|
|
{
|
2011-05-22 17:26:53 +02:00
|
|
|
} activate_read;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2010-08-28 10:15:03 +02:00
|
|
|
// Sent by pipe reader to inform pipe writer about how many
|
|
|
|
// messages it has read so far.
|
2010-03-01 10:13:26 +01:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint64_t msgs_read;
|
2011-05-22 17:26:53 +02:00
|
|
|
} activate_write;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2011-05-30 10:07:34 +02:00
|
|
|
// Sent by pipe reader to writer after creating a new inpipe.
|
|
|
|
// The parameter is actually of type pipe_t::upipe_t, however,
|
|
|
|
// its definition is private so we'll have to do with void*.
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
void *pipe;
|
|
|
|
} hiccup;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-08-28 16:51:46 +02:00
|
|
|
// Sent by pipe reader to pipe writer to ask it to terminate
|
|
|
|
// its end of the pipe.
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
} pipe_term;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-08-28 16:51:46 +02:00
|
|
|
// Pipe writer acknowledges pipe_term command.
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
} pipe_term_ack;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2017-01-11 03:49:54 +01:00
|
|
|
// Sent by one of pipe to another part for modify hwm
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
int inhwm;
|
|
|
|
int outhwm;
|
|
|
|
} pipe_hwm;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-08-08 16:01:58 +02:00
|
|
|
// Sent by I/O object ot the socket to request the shutdown of
|
|
|
|
// the I/O object.
|
2009-07-29 12:07:54 +02:00
|
|
|
struct
|
|
|
|
{
|
2011-11-09 15:22:20 +01:00
|
|
|
zmq::own_t *object;
|
2009-08-08 16:01:58 +02:00
|
|
|
} term_req;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-08-08 16:01:58 +02:00
|
|
|
// Sent by socket to I/O object to start its shutdown.
|
2009-07-29 12:07:54 +02:00
|
|
|
struct
|
|
|
|
{
|
2010-10-16 10:53:29 +02:00
|
|
|
int linger;
|
2009-08-08 16:01:58 +02:00
|
|
|
} term;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-08-08 16:01:58 +02:00
|
|
|
// Sent by I/O object to the socket to acknowledge it has
|
|
|
|
// shut down.
|
2009-07-29 12:07:54 +02:00
|
|
|
struct
|
|
|
|
{
|
2009-08-08 16:01:58 +02:00
|
|
|
} term_ack;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2017-09-19 01:14:10 +02:00
|
|
|
// Sent by session_base (I/O thread) to socket (application thread)
|
|
|
|
// to ask to disconnect the endpoint.
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
std::string *endpoint;
|
|
|
|
} term_endpoint;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2011-02-09 15:32:15 +01:00
|
|
|
// Transfers the ownership of the closed socket
|
|
|
|
// to the reaper thread.
|
|
|
|
struct
|
|
|
|
{
|
2011-11-09 15:22:20 +01:00
|
|
|
zmq::socket_base_t *socket;
|
2011-02-09 15:32:15 +01:00
|
|
|
} reap;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2011-02-09 22:23:21 +01:00
|
|
|
// Closed socket notifies the reaper that it's already deallocated.
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
} reaped;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2019-01-31 17:23:42 +01:00
|
|
|
// Send application-side pipe count and ask to send monitor event
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint64_t queue_count;
|
|
|
|
zmq::own_t *socket_base;
|
|
|
|
endpoint_uri_pair_t *endpoint_pair;
|
|
|
|
} pipe_peer_stats;
|
|
|
|
|
|
|
|
// Collate application thread and I/O thread pipe counts and endpoints
|
|
|
|
// and send as event
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
uint64_t outbound_queue_count;
|
|
|
|
uint64_t inbound_queue_count;
|
|
|
|
endpoint_uri_pair_t *endpoint_pair;
|
|
|
|
} pipe_stats_publish;
|
|
|
|
|
2011-02-09 15:32:15 +01:00
|
|
|
// Sent by reaper thread to the term thread when all the sockets
|
|
|
|
// are successfully deallocated.
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
} done;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2009-07-29 12:07:54 +02:00
|
|
|
} args;
|
2015-01-13 23:47:00 +01:00
|
|
|
#ifdef _MSC_VER
|
2009-07-29 12:07:54 +02:00
|
|
|
};
|
2017-07-27 06:06:19 +02:00
|
|
|
#pragma warning(pop)
|
2015-01-13 23:47:00 +01:00
|
|
|
#else
|
|
|
|
} __attribute__ ((aligned (64)));
|
|
|
|
#endif
|
2015-01-12 20:37:32 +01:00
|
|
|
}
|
2009-07-29 12:07:54 +02:00
|
|
|
|
|
|
|
#endif
|