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

« back to all changes in this revision

Viewing changes to src/xreq.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) 2009-2011 250bpm s.r.o.
 
3
    Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
 
4
 
 
5
    This file is part of 0MQ.
 
6
 
 
7
    0MQ is free software; you can redistribute it and/or modify it under
 
8
    the terms of the GNU Lesser General Public License as published by
 
9
    the Free Software Foundation; either version 3 of the License, or
 
10
    (at your option) any later version.
 
11
 
 
12
    0MQ is distributed in the hope that it will be useful,
 
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
    GNU Lesser General Public License for more details.
 
16
 
 
17
    You should have received a copy of the GNU Lesser General Public License
 
18
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*/
 
20
 
 
21
#ifndef __ZMQ_XREQ_HPP_INCLUDED__
 
22
#define __ZMQ_XREQ_HPP_INCLUDED__
 
23
 
 
24
#include "socket_base.hpp"
 
25
#include "session_base.hpp"
 
26
#include "fq.hpp"
 
27
#include "lb.hpp"
 
28
 
 
29
namespace zmq
 
30
{
 
31
 
 
32
    class ctx_t;
 
33
    class msg_t;
 
34
    class pipe_t;
 
35
    class io_thread_t;
 
36
    class socket_base_t;
 
37
 
 
38
    class xreq_t :
 
39
        public socket_base_t
 
40
    {
 
41
    public:
 
42
 
 
43
        xreq_t (zmq::ctx_t *parent_, uint32_t tid_);
 
44
        ~xreq_t ();
 
45
 
 
46
    protected:
 
47
 
 
48
        //  Overloads of functions from socket_base_t.
 
49
        void xattach_pipe (zmq::pipe_t *pipe_);
 
50
        int xsend (zmq::msg_t *msg_, int flags_);
 
51
        int xrecv (zmq::msg_t *msg_, int flags_);
 
52
        bool xhas_in ();
 
53
        bool xhas_out ();
 
54
        void xread_activated (zmq::pipe_t *pipe_);
 
55
        void xwrite_activated (zmq::pipe_t *pipe_);
 
56
        void xterminated (zmq::pipe_t *pipe_);
 
57
 
 
58
    private:
 
59
 
 
60
        //  Messages are fair-queued from inbound pipes. And load-balanced to
 
61
        //  the outbound pipes.
 
62
        fq_t fq;
 
63
        lb_t lb;
 
64
 
 
65
        //  Have we prefetched a message.
 
66
        bool prefetched;
 
67
 
 
68
        //  Holds the prefetched message.
 
69
        msg_t prefetched_msg;
 
70
 
 
71
        xreq_t (const xreq_t&);
 
72
        const xreq_t &operator = (const xreq_t&);
 
73
    };
 
74
 
 
75
    class xreq_session_t : public session_base_t
 
76
    {
 
77
    public:
 
78
 
 
79
        xreq_session_t (zmq::io_thread_t *io_thread_, bool connect_,
 
80
            zmq::socket_base_t *socket_, const options_t &options_,
 
81
            const char *protocol_, const char *address_);
 
82
        ~xreq_session_t ();
 
83
 
 
84
    private:
 
85
 
 
86
        xreq_session_t (const xreq_session_t&);
 
87
        const xreq_session_t &operator = (const xreq_session_t&);
 
88
    };
 
89
 
 
90
}
 
91
 
 
92
#endif