![]() |
libzmq master
The Intelligent Transport Layer
|
00001 /* 00002 Copyright (c) 2011 250bpm s.r.o. 00003 Copyright (c) 2011 Other contributors as noted in the AUTHORS file 00004 00005 This file is part of 0MQ. 00006 00007 0MQ is free software; you can redistribute it and/or modify it under 00008 the terms of the GNU Lesser General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 0MQ is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #ifndef __ZMQ_REAPER_HPP_INCLUDED__ 00022 #define __ZMQ_REAPER_HPP_INCLUDED__ 00023 00024 #include "object.hpp" 00025 #include "mailbox.hpp" 00026 #include "poller.hpp" 00027 #include "i_poll_events.hpp" 00028 00029 namespace zmq 00030 { 00031 00032 class reaper_t : public object_t, public i_poll_events 00033 { 00034 public: 00035 00036 reaper_t (class ctx_t *ctx_, uint32_t tid_); 00037 ~reaper_t (); 00038 00039 mailbox_t *get_mailbox (); 00040 00041 void start (); 00042 void stop (); 00043 00044 // i_poll_events implementation. 00045 void in_event (); 00046 void out_event (); 00047 void timer_event (int id_); 00048 00049 private: 00050 00051 // Command handlers. 00052 void process_stop (); 00053 void process_reap (class socket_base_t *socket_); 00054 void process_reaped (); 00055 00056 // Reaper thread accesses incoming commands via this mailbox. 00057 mailbox_t mailbox; 00058 00059 // Handle associated with mailbox' file descriptor. 00060 poller_t::handle_t mailbox_handle; 00061 00062 // I/O multiplexing is performed using a poller object. 00063 poller_t *poller; 00064 00065 // Number of sockets being reaped at the moment. 00066 int sockets; 00067 00068 // If true, we were already asked to terminate. 00069 bool terminating; 00070 00071 reaper_t (const reaper_t&); 00072 const reaper_t &operator = (const reaper_t&); 00073 }; 00074 00075 } 00076 00077 #endif