Add support for thread config element which specifies number of
[yazproxy-moved-to-github.git] / src / msg-thread.h
1 /* $Id: msg-thread.h,v 1.11 2006-03-30 14:16:34 adam Exp $
2    Copyright (c) 1998-2006, Index Data.
3
4 This file is part of the yazproxy.
5
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
9 version.
10
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
14 for more details.
15
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
19 02111-1307, USA.
20  */
21
22 #include <yazpp/socket-observer.h>
23 #include <yaz/yconfig.h>
24
25 class YAZ_EXPORT IMsg_Thread {
26 public:
27     virtual IMsg_Thread *handle() = 0;
28     virtual void result() = 0;
29     virtual ~IMsg_Thread();
30 };
31
32 class YAZ_EXPORT Msg_Thread_Queue_List {
33     friend class Msg_Thread_Queue;
34  private:
35     IMsg_Thread *m_item;
36     Msg_Thread_Queue_List *m_next;
37 };
38
39 class YAZ_EXPORT Msg_Thread_Queue {
40  public:
41     Msg_Thread_Queue();
42     void enqueue(IMsg_Thread *in);
43     IMsg_Thread *dequeue();
44     int size();
45  private:
46     Msg_Thread_Queue_List *m_list;
47 };
48
49 class YAZ_EXPORT Msg_Thread : public yazpp_1::ISocketObserver {
50     class Private;
51  public:
52     Msg_Thread(yazpp_1::ISocketObservable *obs, int no_threads);
53     virtual ~Msg_Thread();
54     void socketNotify(int event);
55     void put(IMsg_Thread *m);
56     IMsg_Thread *get();
57     void run(void *p);
58 private:
59     class Private *m_p;
60 };
61
62 /*
63  * Local variables:
64  * c-basic-offset: 4
65  * indent-tabs-mode: nil
66  * End:
67  * vim: shiftwidth=4 tabstop=8 expandtab
68  */
69