libzmq master
The Intelligent Transport Layer

command.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright (c) 2009-2011 250bpm s.r.o.
00003     Copyright (c) 2007-2009 iMatix Corporation
00004     Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
00005 
00006     This file is part of 0MQ.
00007 
00008     0MQ is free software; you can redistribute it and/or modify it under
00009     the terms of the GNU Lesser General Public License as published by
00010     the Free Software Foundation; either version 3 of the License, or
00011     (at your option) any later version.
00012 
00013     0MQ is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public License
00019     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020 */
00021 
00022 #ifndef __ZMQ_COMMAND_HPP_INCLUDED__
00023 #define __ZMQ_COMMAND_HPP_INCLUDED__
00024 
00025 #include "stdint.hpp"
00026 
00027 namespace zmq
00028 {
00029 
00030     //  This structure defines the commands that can be sent between threads.
00031 
00032     struct command_t
00033     {
00034         //  Object to process the command.
00035         class object_t *destination;
00036 
00037         enum type_t
00038         {
00039             stop,
00040             plug,
00041             own,
00042             attach,
00043             bind,
00044             activate_read,
00045             activate_write,
00046             hiccup,
00047             pipe_term,
00048             pipe_term_ack,
00049             term_req,
00050             term,
00051             term_ack,
00052             reap,
00053             reaped,
00054             done
00055         } type;
00056 
00057         union {
00058 
00059             //  Sent to I/O thread to let it know that it should
00060             //  terminate itself.
00061             struct {
00062             } stop;
00063 
00064             //  Sent to I/O object to make it register with its I/O thread.
00065             struct {
00066             } plug;
00067 
00068             //  Sent to socket to let it know about the newly created object.
00069             struct {
00070                 class own_t *object;
00071             } own;
00072 
00073             //  Attach the engine to the session. If engine is NULL, it informs
00074             //  session that the connection have failed.
00075             struct {
00076                 struct i_engine *engine;
00077             } attach;
00078 
00079             //  Sent from session to socket to establish pipe(s) between them.
00080             //  Caller have used inc_seqnum beforehand sending the command.
00081             struct {
00082                 class pipe_t *pipe;
00083             } bind;
00084 
00085             //  Sent by pipe writer to inform dormant pipe reader that there
00086             //  are messages in the pipe.
00087             struct {
00088             } activate_read;
00089 
00090             //  Sent by pipe reader to inform pipe writer about how many
00091             //  messages it has read so far.
00092             struct {
00093                 uint64_t msgs_read;
00094             } activate_write;
00095 
00096             //  Sent by pipe reader to writer after creating a new inpipe.
00097             //  The parameter is actually of type pipe_t::upipe_t, however,
00098             //  its definition is private so we'll have to do with void*.
00099             struct {
00100                 void *pipe;
00101             } hiccup;
00102 
00103             //  Sent by pipe reader to pipe writer to ask it to terminate
00104             //  its end of the pipe.
00105             struct {
00106             } pipe_term;
00107 
00108             //  Pipe writer acknowledges pipe_term command.
00109             struct {
00110             } pipe_term_ack;
00111 
00112             //  Sent by I/O object ot the socket to request the shutdown of
00113             //  the I/O object.
00114             struct {
00115                 class own_t *object;
00116             } term_req;
00117 
00118             //  Sent by socket to I/O object to start its shutdown.
00119             struct {
00120                 int linger;
00121             } term;
00122 
00123             //  Sent by I/O object to the socket to acknowledge it has
00124             //  shut down.
00125             struct {
00126             } term_ack;
00127 
00128             //  Transfers the ownership of the closed socket
00129             //  to the reaper thread.
00130             struct {
00131                 class socket_base_t *socket;
00132             } reap;
00133 
00134             //  Closed socket notifies the reaper that it's already deallocated.
00135             struct {
00136             } reaped;
00137 
00138             //  Sent by reaper thread to the term thread when all the sockets
00139             //  are successfully deallocated.
00140             struct {
00141             } done;
00142 
00143         } args;
00144     };
00145 
00146 }    
00147 
00148 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines