libzmq  master
ZeroMQ C++ Core Engine (LIBZMQ)
fq.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
3 
4  This file is part of libzmq, the ZeroMQ core engine in C++.
5 
6  libzmq is free software; you can redistribute it and/or modify it under
7  the terms of the GNU Lesser General Public License (LGPL) as published
8  by the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  As a special exception, the Contributors give you permission to link
12  this library with independent modules to produce an executable,
13  regardless of the license terms of these independent modules, and to
14  copy and distribute the resulting executable under terms of your choice,
15  provided that you also meet, for each linked independent module, the
16  terms and conditions of the license of that module. An independent
17  module is a module which is not derived from or based on this library.
18  If you modify this library, you must extend this exception to your
19  version of the library.
20 
21  libzmq is distributed in the hope that it will be useful, but WITHOUT
22  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
24  License for more details.
25 
26  You should have received a copy of the GNU Lesser General Public License
27  along with this program. If not, see <http://www.gnu.org/licenses/>.
28 */
29 
30 #ifndef __ZMQ_FQ_HPP_INCLUDED__
31 #define __ZMQ_FQ_HPP_INCLUDED__
32 
33 #include "array.hpp"
34 #include "blob.hpp"
35 #include "pipe.hpp"
36 #include "msg.hpp"
37 
38 namespace zmq
39 {
40 
41  // Class manages a set of inbound pipes. On receive it performs fair
42  // queueing so that senders gone berserk won't cause denial of
43  // service for decent senders.
44 
45  class fq_t
46  {
47  public:
48 
49  fq_t ();
50  ~fq_t ();
51 
52  void attach (pipe_t *pipe_);
53  void activated (pipe_t *pipe_);
54  void pipe_terminated (pipe_t *pipe_);
55 
56  int recv (msg_t *msg_);
57  int recvpipe (msg_t *msg_, pipe_t **pipe_);
58  bool has_in ();
59  blob_t get_credential () const;
60 
61  private:
62 
63  // Inbound pipes.
65  pipes_t pipes;
66 
67  // Number of active pipes. All the active pipes are located at the
68  // beginning of the pipes array.
70 
71  // Pointer to the last pipe we received message from.
72  // NULL when no message has been received or the pipe
73  // has terminated.
75 
76  // Index of the next bound pipe to read a message from.
78 
79  // If true, part of a multipart message was already received, but
80  // there are following parts still waiting in the current pipe.
81  bool more;
82 
83  // Holds credential after the last_active_pipe has terminated.
85 
86  fq_t (const fq_t&);
87  const fq_t &operator = (const fq_t&);
88  };
89 
90 }
91 
92 #endif
~fq_t()
Definition: fq.cpp:44
blob_t get_credential() const
Definition: fq.cpp:158
std::vector< pipe_t * >::size_type size_type
Definition: array.hpp:93
bool more
Definition: fq.hpp:81
int recvpipe(msg_t *msg_, pipe_t **pipe_)
Definition: fq.cpp:88
void pipe_terminated(pipe_t *pipe_)
Definition: fq.cpp:56
pipes_t::size_type current
Definition: fq.hpp:77
fq_t()
Definition: fq.cpp:36
void attach(pipe_t *pipe_)
Definition: fq.cpp:49
bool has_in()
Definition: fq.cpp:134
std::basic_string< unsigned char > blob_t
Definition: blob.hpp:134
pipes_t::size_type active
Definition: fq.hpp:69
int recv(msg_t *msg_)
Definition: fq.cpp:83
void activated(pipe_t *pipe_)
Definition: fq.cpp:76
const fq_t & operator=(const fq_t &)
pipes_t pipes
Definition: fq.hpp:65
array_t< pipe_t, 1 > pipes_t
Definition: fq.hpp:64
pipe_t * last_in
Definition: fq.hpp:74
Definition: address.hpp:35
Definition: fq.hpp:45
blob_t saved_credential
Definition: fq.hpp:84