~ubuntu-branches/ubuntu/saucy/zeromq3/saucy

« back to all changes in this revision

Viewing changes to src/lb.hpp

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2012-06-04 21:21:09 UTC
  • Revision ID: package-import@ubuntu.com-20120604212109-b7b3m0rn21o8oo2q
Tags: upstream-3.1.0~beta+dfsg
ImportĀ upstreamĀ versionĀ 3.1.0~beta+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2010-2011 250bpm s.r.o.
 
3
    Copyright (c) 2007-2009 iMatix Corporation
 
4
    Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
 
5
 
 
6
    This file is part of 0MQ.
 
7
 
 
8
    0MQ is free software; you can redistribute it and/or modify it under
 
9
    the terms of the GNU Lesser General Public License as published by
 
10
    the Free Software Foundation; either version 3 of the License, or
 
11
    (at your option) any later version.
 
12
 
 
13
    0MQ is distributed in the hope that it will be useful,
 
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
    GNU Lesser General Public License for more details.
 
17
 
 
18
    You should have received a copy of the GNU Lesser General Public License
 
19
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
*/
 
21
 
 
22
#ifndef __ZMQ_LB_HPP_INCLUDED__
 
23
#define __ZMQ_LB_HPP_INCLUDED__
 
24
 
 
25
#include "array.hpp"
 
26
#include "pipe.hpp"
 
27
 
 
28
namespace zmq
 
29
{
 
30
 
 
31
    //  This class manages a set of outbound pipes. On send it load balances
 
32
    //  messages fairly among the pipes.
 
33
 
 
34
    class lb_t
 
35
    {
 
36
    public:
 
37
 
 
38
        lb_t ();
 
39
        ~lb_t ();
 
40
 
 
41
        void attach (pipe_t *pipe_);
 
42
        void activated (pipe_t *pipe_);
 
43
        void terminated (pipe_t *pipe_);
 
44
 
 
45
        int send (msg_t *msg_, int flags_);
 
46
        bool has_out ();
 
47
 
 
48
    private:
 
49
 
 
50
        //  List of outbound pipes.
 
51
        typedef array_t <pipe_t, 2> pipes_t;
 
52
        pipes_t pipes;
 
53
 
 
54
        //  Number of active pipes. All the active pipes are located at the
 
55
        //  beginning of the pipes array.
 
56
        pipes_t::size_type active;
 
57
 
 
58
        //  Points to the last pipe that the most recent message was sent to.
 
59
        pipes_t::size_type current;
 
60
 
 
61
        //  True if last we are in the middle of a multipart message.
 
62
        bool more;
 
63
 
 
64
        //  True if we are dropping current message.
 
65
        bool dropping;
 
66
 
 
67
        lb_t (const lb_t&);
 
68
        const lb_t &operator = (const lb_t&);
 
69
    };
 
70
 
 
71
}
 
72
 
 
73
#endif