libzmq  master
ZeroMQ C++ Core Engine (LIBZMQ)
io_object.cpp
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 #include "precompiled.hpp"
31 #include "io_object.hpp"
32 #include "io_thread.hpp"
33 #include "err.hpp"
34 
36  poller (NULL)
37 {
38  if (io_thread_)
39  plug (io_thread_);
40 }
41 
43 {
44 }
45 
47 {
48  zmq_assert (io_thread_);
49  zmq_assert (!poller);
50 
51  // Retrieve the poller from the thread we are running in.
52  poller = io_thread_->get_poller ();
53 }
54 
56 {
58 
59  // Forget about old poller in preparation to be migrated
60  // to a different I/O thread.
61  poller = NULL;
62 }
63 
65 {
66  return poller->add_fd (fd_, this);
67 }
68 
70 {
71  poller->rm_fd (handle_);
72 }
73 
75 {
76  poller->set_pollin (handle_);
77 }
78 
80 {
81  poller->reset_pollin (handle_);
82 }
83 
85 {
86  poller->set_pollout (handle_);
87 }
88 
90 {
91  poller->reset_pollout (handle_);
92 }
93 
94 void zmq::io_object_t::add_timer (int timeout_, int id_)
95 {
96  poller->add_timer (timeout_, this, id_);
97 }
98 
100 {
101  poller->cancel_timer (this, id_);
102 }
103 
105 {
106  zmq_assert (false);
107 }
108 
110 {
111  zmq_assert (false);
112 }
113 
115 {
116  zmq_assert (false);
117 }
void set_pollout(handle_t handle_)
Definition: io_object.cpp:84
void plug(zmq::io_thread_t *io_thread_)
Definition: io_object.cpp:46
#define zmq_assert(x)
Definition: err.hpp:119
void cancel_timer(int id_)
Definition: io_object.cpp:99
poller_t * poller
Definition: io_object.hpp:81
void set_pollin(handle_t handle_)
Definition: io_object.cpp:74
poller_t * get_poller()
Definition: io_thread.cpp:104
void timer_event(int id_)
Definition: io_object.cpp:114
void reset_pollout(handle_t handle_)
Definition: io_object.cpp:89
void add_timer(int timout_, int id_)
Definition: io_object.cpp:94
void reset_pollin(handle_t handle_)
Definition: io_object.cpp:79
handle_t add_fd(fd_t fd_)
Definition: io_object.cpp:64
io_object_t(zmq::io_thread_t *io_thread_=NULL)
Definition: io_object.cpp:35
void rm_fd(handle_t handle_)
Definition: io_object.cpp:69
poller_t::handle_t handle_t
Definition: io_object.hpp:62