X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fthread_pool_observer.hpp;h=630b39b3d865ce86c26632927dbb4861f7a338c3;hb=586d78659d671683f33ec55f4a7d32b28e345ccd;hp=4f9636d4ab2f28ea1c8ca9b7b1536ccbcfe099c6;hpb=cea1fb12604fd1ddbac6804b95c4aff078d30409;p=metaproxy-moved-to-github.git diff --git a/src/thread_pool_observer.hpp b/src/thread_pool_observer.hpp index 4f9636d..630b39b 100644 --- a/src/thread_pool_observer.hpp +++ b/src/thread_pool_observer.hpp @@ -1,83 +1,61 @@ -/* $Id: thread_pool_observer.hpp,v 1.2 2005-10-14 10:08:40 adam Exp $ - Copyright (c) 1998-2005, Index Data. +/* This file is part of Metaproxy. + Copyright (C) Index Data -This file is part of the yaz-proxy. - -YAZ proxy is free software; you can redistribute it and/or modify it under +Metaproxy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. -YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with YAZ proxy; see the file LICENSE. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. - */ +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #ifndef YP2_THREAD_POOL_OBSERVER_HPP #define YP2_THREAD_POOL_OBSERVER_HPP -#include -#include -#include +#include -#include -#include - -#include -#include +#include #include -class IThreadPoolMsg { -public: - virtual IThreadPoolMsg *handle() = 0; - virtual void result() = 0; - virtual ~IThreadPoolMsg(); -}; - -class ThreadPoolSocketObserver : public yazpp_1::ISocketObserver { -private: - class Worker { +namespace metaproxy_1 { + class IThreadPoolMsg { public: - Worker(ThreadPoolSocketObserver *s) : m_s(s) {}; - ThreadPoolSocketObserver *m_s; - void operator() (void) { - m_s->run(0); - } + virtual IThreadPoolMsg *handle() = 0; + virtual void result(const char *info) = 0; + virtual ~IThreadPoolMsg(); + virtual bool cleanup(void *info) = 0; }; -public: - ThreadPoolSocketObserver(yazpp_1::ISocketObservable *obs, int no_threads); - virtual ~ThreadPoolSocketObserver(); - void socketNotify(int event); - void put(IThreadPoolMsg *m); - IThreadPoolMsg *get(); - void run(void *p); - int m_fd[2]; -private: - yazpp_1::ISocketObservable *m_SocketObservable; - int m_no_threads; - boost::thread_group m_thrds; - std::deque m_input; - std::deque m_output; - - boost::mutex m_mutex_input_data; - boost::condition m_cond_input_data; - boost::mutex m_mutex_output_data; - bool m_stop_flag; - - -}; + class ThreadPoolSocketObserver : public yazpp_1::ISocketObserver { + class Rep; + class Worker; + public: + ThreadPoolSocketObserver(yazpp_1::ISocketObservable *obs, + int no_threads); + virtual ~ThreadPoolSocketObserver(); + void put(IThreadPoolMsg *m); + void cleanup(IThreadPoolMsg *m, void *info); + IThreadPoolMsg *get(); + void run(void *p); + void get_thread_info(int &tbusy, int &total); + private: + void socketNotify(int event); + boost::scoped_ptr m_p; + }; +} #endif /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab