GPL v2.
[metaproxy-moved-to-github.git] / src / thread_pool_observer.hpp
1 /* $Id: thread_pool_observer.hpp,v 1.12 2007-05-09 21:23:09 adam Exp $
2    Copyright (c) 2005-2007, Index Data.
3
4 This file is part of Metaproxy.
5
6 Metaproxy 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
9 version.
10
11 Metaproxy 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
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Metaproxy; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 #ifndef YP2_THREAD_POOL_OBSERVER_HPP
23 #define YP2_THREAD_POOL_OBSERVER_HPP
24
25 #include <boost/scoped_ptr.hpp>
26
27 #include <yazpp/socket-observer.h>
28 #include <yaz/yconfig.h>
29
30 namespace metaproxy_1 {
31     class IThreadPoolMsg {
32     public:
33         virtual IThreadPoolMsg *handle() = 0;
34         virtual void result() = 0;
35         virtual ~IThreadPoolMsg();
36     };
37
38     class ThreadPoolSocketObserver : public yazpp_1::ISocketObserver {
39         class Rep;
40         class Worker;
41     public:
42         ThreadPoolSocketObserver(yazpp_1::ISocketObservable *obs,
43                                  int no_threads);
44         virtual ~ThreadPoolSocketObserver();
45         void put(IThreadPoolMsg *m);
46         IThreadPoolMsg *get();
47         void run(void *p);
48     private:
49         void socketNotify(int event);
50         boost::scoped_ptr<Rep> m_p;
51
52     };
53 }
54 #endif
55 /*
56  * Local variables:
57  * c-basic-offset: 4
58  * indent-tabs-mode: nil
59  * c-file-style: "stroustrup"
60  * End:
61  * vim: shiftwidth=4 tabstop=8 expandtab
62  */
63