libzmq master
The Intelligent Transport Layer

lb.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright (c) 2010-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_LB_HPP_INCLUDED__
00023 #define __ZMQ_LB_HPP_INCLUDED__
00024 
00025 #include "array.hpp"
00026 #include "pipe.hpp"
00027 
00028 namespace zmq
00029 {
00030 
00031     //  This class manages a set of outbound pipes. On send it load balances
00032     //  messages fairly among the pipes.
00033 
00034     class lb_t
00035     {
00036     public:
00037 
00038         lb_t ();
00039         ~lb_t ();
00040 
00041         void attach (pipe_t *pipe_);
00042         void activated (pipe_t *pipe_);
00043         void terminated (pipe_t *pipe_);
00044 
00045         int send (msg_t *msg_, int flags_);
00046         bool has_out ();
00047 
00048     private:
00049 
00050         //  List of outbound pipes.
00051         typedef array_t <class pipe_t, 2> pipes_t;
00052         pipes_t pipes;
00053 
00054         //  Number of active pipes. All the active pipes are located at the
00055         //  beginning of the pipes array.
00056         pipes_t::size_type active;
00057 
00058         //  Points to the last pipe that the most recent message was sent to.
00059         pipes_t::size_type current;
00060 
00061         //  True if last we are in the middle of a multipart message.
00062         bool more;
00063 
00064         //  True if we are dropping current message.
00065         bool dropping;
00066 
00067         lb_t (const lb_t&);
00068         const lb_t &operator = (const lb_t&);
00069     };
00070 
00071 }
00072 
00073 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines