libzmq master
The Intelligent Transport Layer

io_object.cpp

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 #include "io_object.hpp"
00023 #include "io_thread.hpp"
00024 #include "err.hpp"
00025 
00026 zmq::io_object_t::io_object_t (io_thread_t *io_thread_) :
00027     poller (NULL)
00028 {
00029     if (io_thread_)
00030         plug (io_thread_);
00031 }
00032 
00033 zmq::io_object_t::~io_object_t ()
00034 {
00035 }
00036 
00037 void zmq::io_object_t::plug (io_thread_t *io_thread_)
00038 {
00039     zmq_assert (io_thread_);
00040     zmq_assert (!poller);
00041 
00042     //  Retrieve the poller from the thread we are running in.
00043     poller = io_thread_->get_poller ();
00044 }
00045 
00046 void zmq::io_object_t::unplug ()
00047 {
00048     zmq_assert (poller);
00049 
00050     //  Forget about old poller in preparation to be migrated
00051     //  to a different I/O thread.
00052     poller = NULL;
00053 }
00054 
00055 zmq::io_object_t::handle_t zmq::io_object_t::add_fd (fd_t fd_)
00056 {
00057     return poller->add_fd (fd_, this);
00058 }
00059 
00060 void zmq::io_object_t::rm_fd (handle_t handle_)
00061 {
00062     poller->rm_fd (handle_);
00063 }
00064 
00065 void zmq::io_object_t::set_pollin (handle_t handle_)
00066 {
00067     poller->set_pollin (handle_);
00068 }
00069 
00070 void zmq::io_object_t::reset_pollin (handle_t handle_)
00071 {
00072     poller->reset_pollin (handle_);
00073 }
00074 
00075 void zmq::io_object_t::set_pollout (handle_t handle_)
00076 {
00077     poller->set_pollout (handle_);
00078 }
00079 
00080 void zmq::io_object_t::reset_pollout (handle_t handle_)
00081 {
00082     poller->reset_pollout (handle_);
00083 }
00084 
00085 void zmq::io_object_t::add_timer (int timeout_, int id_)
00086 {
00087     poller->add_timer (timeout_, this, id_);
00088 }
00089 
00090 void zmq::io_object_t::cancel_timer (int id_)
00091 {
00092     poller->cancel_timer (this, id_);
00093 }
00094 
00095 void zmq::io_object_t::in_event ()
00096 {
00097     zmq_assert (false);
00098 }
00099 
00100 void zmq::io_object_t::out_event ()
00101 {
00102     zmq_assert (false);
00103 }
00104 
00105 void zmq::io_object_t::timer_event (int id_)
00106 {
00107     zmq_assert (false);
00108 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines