libzmq master
The Intelligent Transport Layer

fq.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_FQ_HPP_INCLUDED__
00023 #define __ZMQ_FQ_HPP_INCLUDED__
00024 
00025 #include "array.hpp"
00026 #include "pipe.hpp"
00027 #include "msg.hpp"
00028 
00029 namespace zmq
00030 {
00031 
00032     //  Class manages a set of inbound pipes. On receive it performs fair
00033     //  queueing so that senders gone berserk won't cause denial of
00034     //  service for decent senders.
00035 
00036     class fq_t
00037     {
00038     public:
00039 
00040         fq_t ();
00041         ~fq_t ();
00042 
00043         void attach (pipe_t *pipe_);
00044         void activated (pipe_t *pipe_);
00045         void terminated (pipe_t *pipe_);
00046 
00047         int recv (msg_t *msg_, int flags_);
00048         int recvpipe (msg_t *msg_, int flags_, pipe_t **pipe_);
00049         bool has_in ();
00050 
00051     private:
00052 
00053         //  Inbound pipes.
00054         typedef array_t <pipe_t, 1> pipes_t;
00055         pipes_t pipes;
00056 
00057         //  Number of active pipes. All the active pipes are located at the
00058         //  beginning of the pipes array.
00059         pipes_t::size_type active;
00060 
00061         //  Index of the next bound pipe to read a message from.
00062         pipes_t::size_type current;
00063 
00064         //  If true, part of a multipart message was already received, but
00065         //  there are following parts still waiting in the current pipe.
00066         bool more;
00067 
00068         fq_t (const fq_t&);
00069         const fq_t &operator = (const fq_t&);
00070     };
00071 
00072 }
00073 
00074 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines