~ubuntu-branches/ubuntu/wily/zeromq3/wily-proposed

« back to all changes in this revision

Viewing changes to src/lb.cpp

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2014-03-16 14:02:28 UTC
  • mfrom: (1.1.6) (6.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140316140228-ig1sgh7czk59m9ux
Tags: 4.0.4+dfsg-1
* QA upload; orphan the package
  - Upload to unstable
* New upstream release
* Update repack.stub script
* Drop 02_fix-exported-symbols.patch and 03_fix-s390-rdtsc.patch
  (merged upstream)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
    Copyright (c) 2010-2011 250bpm s.r.o.
3
 
    Copyright (c) 2007-2009 iMatix Corporation
4
 
    Copyright (c) 2011 VMware, Inc.
5
 
    Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
 
2
    Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
6
3
 
7
4
    This file is part of 0MQ.
8
5
 
44
41
    activated (pipe_);
45
42
}
46
43
 
47
 
void zmq::lb_t::terminated (pipe_t *pipe_)
 
44
void zmq::lb_t::pipe_terminated (pipe_t *pipe_)
48
45
{
49
46
    pipes_t::size_type index = pipes.index (pipe_);
50
47
 
71
68
    active++;
72
69
}
73
70
 
74
 
int zmq::lb_t::send (msg_t *msg_, int flags_)
 
71
int zmq::lb_t::send (msg_t *msg_)
75
72
{
76
 
    // flags_ is unused
77
 
    (void)flags_;
 
73
    return sendpipe (msg_, NULL);
 
74
}
78
75
 
 
76
int zmq::lb_t::sendpipe (msg_t *msg_, pipe_t **pipe_)
 
77
{
79
78
    //  Drop the message if required. If we are at the end of the message
80
79
    //  switch back to non-dropping mode.
81
80
    if (dropping) {
92
91
 
93
92
    while (active > 0) {
94
93
        if (pipes [current]->write (msg_))
 
94
        {
 
95
            if (pipe_)
 
96
                *pipe_ = pipes [current];
95
97
            break;
 
98
        }
96
99
 
97
100
        zmq_assert (!more);
98
101
        active--;
108
111
        return -1;
109
112
    }
110
113
 
111
 
    //  If it's final part of the message we can fluch it downstream and
112
 
    //  continue round-robinning (load balance).
 
114
    //  If it's final part of the message we can flush it downstream and
 
115
    //  continue round-robining (load balance).
113
116
    more = msg_->flags () & msg_t::more? true: false;
114
117
    if (!more) {
115
118
        pipes [current]->flush ();
145
148
 
146
149
    return false;
147
150
}
148