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

« back to all changes in this revision

Viewing changes to src/io_object.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-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_IO_OBJECT_HPP_INCLUDED__
 
23
#define __ZMQ_IO_OBJECT_HPP_INCLUDED__
 
24
 
 
25
#include <stddef.h>
 
26
 
 
27
#include "stdint.hpp"
 
28
#include "poller.hpp"
 
29
#include "i_poll_events.hpp"
 
30
 
 
31
namespace zmq
 
32
{
 
33
 
 
34
    class io_thread_t;
 
35
 
 
36
    //  Simple base class for objects that live in I/O threads.
 
37
    //  It makes communication with the poller object easier and
 
38
    //  makes defining unneeded event handlers unnecessary.
 
39
 
 
40
    class io_object_t : public i_poll_events
 
41
    {
 
42
    public:
 
43
 
 
44
        io_object_t (zmq::io_thread_t *io_thread_ = NULL);
 
45
        ~io_object_t ();
 
46
 
 
47
        //  When migrating an object from one I/O thread to another, first
 
48
        //  unplug it, then migrate it, then plug it to the new thread.
 
49
        void plug (zmq::io_thread_t *io_thread_);
 
50
        void unplug ();
 
51
 
 
52
    protected:
 
53
 
 
54
        typedef poller_t::handle_t handle_t;
 
55
 
 
56
        //  Methods to access underlying poller object.
 
57
        handle_t add_fd (fd_t fd_);
 
58
        void rm_fd (handle_t handle_);
 
59
        void set_pollin (handle_t handle_);
 
60
        void reset_pollin (handle_t handle_);
 
61
        void set_pollout (handle_t handle_);
 
62
        void reset_pollout (handle_t handle_);
 
63
        void add_timer (int timout_, int id_);
 
64
        void cancel_timer (int id_);
 
65
 
 
66
        //  i_poll_events interface implementation.
 
67
        void in_event ();
 
68
        void out_event ();
 
69
        void timer_event (int id_);
 
70
 
 
71
    private:
 
72
 
 
73
        poller_t *poller;
 
74
 
 
75
        io_object_t (const io_object_t&);
 
76
        const io_object_t &operator = (const io_object_t&);
 
77
    };
 
78
 
 
79
}
 
80
 
 
81
#endif