mcproxy/mcproxy/include/proxy/worker.hpp
Go to the documentation of this file.00001 /* 00002 * This file is part of mcproxy. 00003 * 00004 * mcproxy is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Lesser General Public License as published by 00006 * the Free Software Foundation; either version 3 of the License, or (at your 00007 * option) any later version. 00008 * 00009 * mcproxy is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00011 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00012 * License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public License 00015 * along with mcproxy; see the file COPYING.LESSER. 00016 * 00017 * written by Sebastian Woelke, in cooperation with: 00018 * INET group, Hamburg University of Applied Sciences, 00019 * Website: http://mcproxy.realmv6.org/ 00020 */ 00021 00027 #ifndef WORKER_HPP 00028 #define WORKER_HPP 00029 00030 #include "include/proxy/message_queue.hpp" 00031 #include "include/proxy/message_format.hpp" 00032 #include "boost/thread.hpp" 00033 00037 class worker{ 00038 private: 00039 worker(); 00040 boost::thread* m_worker_thread; 00041 00042 static void worker_thread_starter(worker* w); 00043 00044 void close(); 00045 protected: 00046 00050 virtual void worker_thread()=0; 00051 00055 bool m_running; 00056 00060 message_queue<proxy_msg> m_job_queue; 00061 public: 00062 00067 worker(int max_msg); 00068 00069 ~worker(); 00070 00074 void add_msg(proxy_msg& msg); 00075 00079 void start(); 00080 00084 bool is_running(); 00085 00089 void join(); 00090 }; 00091 00092 #endif // WORKER_HPP 00093