1 /* $Id: thread_pool_observer.hpp,v 1.4 2005-10-15 14:09:09 adam Exp $
2 Copyright (c) 2005, Index Data.
7 #ifndef YP2_THREAD_POOL_OBSERVER_HPP
8 #define YP2_THREAD_POOL_OBSERVER_HPP
10 #include <boost/thread/thread.hpp>
11 #include <boost/thread/mutex.hpp>
12 #include <boost/thread/condition.hpp>
18 #include <yaz++/socket-observer.h>
19 #include <yaz/yconfig.h>
22 class IThreadPoolMsg {
24 virtual IThreadPoolMsg *handle() = 0;
25 virtual void result() = 0;
26 virtual ~IThreadPoolMsg();
29 class ThreadPoolSocketObserver : public yazpp_1::ISocketObserver {
33 Worker(ThreadPoolSocketObserver *s) : m_s(s) {};
34 ThreadPoolSocketObserver *m_s;
35 void operator() (void) {
40 ThreadPoolSocketObserver(yazpp_1::ISocketObservable *obs,
42 virtual ~ThreadPoolSocketObserver();
43 void socketNotify(int event);
44 void put(IThreadPoolMsg *m);
45 IThreadPoolMsg *get();
49 yazpp_1::ISocketObservable *m_SocketObservable;
51 boost::thread_group m_thrds;
53 std::deque<IThreadPoolMsg *> m_input;
54 std::deque<IThreadPoolMsg *> m_output;
56 boost::mutex m_mutex_input_data;
57 boost::condition m_cond_input_data;
58 boost::mutex m_mutex_output_data;
68 * indent-tabs-mode: nil
69 * c-file-style: "stroustrup"
71 * vim: shiftwidth=4 tabstop=8 expandtab