1 /* $Id: thread_pool_observer.hpp,v 1.2 2005-10-14 10:08:40 adam Exp $
2 Copyright (c) 1998-2005, Index Data.
4 This file is part of the yaz-proxy.
6 YAZ proxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with YAZ proxy; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #ifndef YP2_THREAD_POOL_OBSERVER_HPP
23 #define YP2_THREAD_POOL_OBSERVER_HPP
25 #include <boost/thread/thread.hpp>
26 #include <boost/thread/mutex.hpp>
27 #include <boost/thread/condition.hpp>
33 #include <yaz++/socket-observer.h>
34 #include <yaz/yconfig.h>
36 class IThreadPoolMsg {
38 virtual IThreadPoolMsg *handle() = 0;
39 virtual void result() = 0;
40 virtual ~IThreadPoolMsg();
43 class ThreadPoolSocketObserver : public yazpp_1::ISocketObserver {
47 Worker(ThreadPoolSocketObserver *s) : m_s(s) {};
48 ThreadPoolSocketObserver *m_s;
49 void operator() (void) {
54 ThreadPoolSocketObserver(yazpp_1::ISocketObservable *obs, int no_threads);
55 virtual ~ThreadPoolSocketObserver();
56 void socketNotify(int event);
57 void put(IThreadPoolMsg *m);
58 IThreadPoolMsg *get();
62 yazpp_1::ISocketObservable *m_SocketObservable;
64 boost::thread_group m_thrds;
66 std::deque<IThreadPoolMsg *> m_input;
67 std::deque<IThreadPoolMsg *> m_output;
69 boost::mutex m_mutex_input_data;
70 boost::condition m_cond_input_data;
71 boost::mutex m_mutex_output_data;
81 * indent-tabs-mode: nil
83 * vim: shiftwidth=4 tabstop=8 expandtab