Line data Source code
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 : #include "precompiled.hpp"
31 : #include "io_object.hpp"
32 : #include "io_thread.hpp"
33 : #include "err.hpp"
34 :
35 18308 : zmq::io_object_t::io_object_t (io_thread_t *io_thread_) :
36 36616 : poller (NULL)
37 : {
38 18308 : if (io_thread_)
39 11541 : plug (io_thread_);
40 18308 : }
41 :
42 18306 : zmq::io_object_t::~io_object_t ()
43 : {
44 18306 : }
45 :
46 18308 : void zmq::io_object_t::plug (io_thread_t *io_thread_)
47 : {
48 18308 : zmq_assert (io_thread_);
49 18308 : zmq_assert (!poller);
50 :
51 : // Retrieve the poller from the thread we are running in.
52 18308 : poller = io_thread_->get_poller ();
53 18308 : }
54 :
55 6768 : void zmq::io_object_t::unplug ()
56 : {
57 6768 : zmq_assert (poller);
58 :
59 : // Forget about old poller in preparation to be migrated
60 : // to a different I/O thread.
61 6768 : poller = NULL;
62 6768 : }
63 :
64 10959 : zmq::io_object_t::handle_t zmq::io_object_t::add_fd (fd_t fd_)
65 : {
66 10959 : return poller->add_fd (fd_, this);
67 : }
68 :
69 10957 : void zmq::io_object_t::rm_fd (handle_t handle_)
70 : {
71 10957 : poller->rm_fd (handle_);
72 10959 : }
73 :
74 7332 : void zmq::io_object_t::set_pollin (handle_t handle_)
75 : {
76 7332 : poller->set_pollin (handle_);
77 7333 : }
78 :
79 239 : void zmq::io_object_t::reset_pollin (handle_t handle_)
80 : {
81 239 : poller->reset_pollin (handle_);
82 239 : }
83 :
84 22998 : void zmq::io_object_t::set_pollout (handle_t handle_)
85 : {
86 22998 : poller->set_pollout (handle_);
87 22997 : }
88 :
89 17954 : void zmq::io_object_t::reset_pollout (handle_t handle_)
90 : {
91 17954 : poller->reset_pollout (handle_);
92 17956 : }
93 :
94 7290 : void zmq::io_object_t::add_timer (int timeout_, int id_)
95 : {
96 7290 : poller->add_timer (timeout_, this, id_);
97 7289 : }
98 :
99 7053 : void zmq::io_object_t::cancel_timer (int id_)
100 : {
101 7053 : poller->cancel_timer (this, id_);
102 7053 : }
103 :
104 0 : void zmq::io_object_t::in_event ()
105 : {
106 0 : zmq_assert (false);
107 0 : }
108 :
109 0 : void zmq::io_object_t::out_event ()
110 : {
111 0 : zmq_assert (false);
112 0 : }
113 :
114 0 : void zmq::io_object_t::timer_event (int)
115 : {
116 0 : zmq_assert (false);
117 0 : }
|