Allos Msg_Thread to operate in non-threaded mode
[yazproxy-moved-to-github.git] / src / msg-thread.h
1 /* $Id: msg-thread.h,v 1.10 2006-03-30 13:29:23 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 <unistd.h>
23 #include <ctype.h>
24
25 #include <yazpp/socket-observer.h>
26 #include <yaz/yconfig.h>
27
28 class IMsg_Thread {
29 public:
30     virtual IMsg_Thread *handle() = 0;
31     virtual void result() = 0;
32     virtual ~IMsg_Thread();
33 };
34
35 class Msg_Thread_Queue_List {
36     friend class Msg_Thread_Queue;
37  private:
38     IMsg_Thread *m_item;
39     Msg_Thread_Queue_List *m_next;
40 };
41
42 class Msg_Thread_Queue {
43  public:
44     Msg_Thread_Queue();
45     void enqueue(IMsg_Thread *in);
46     IMsg_Thread *dequeue();
47     int size();
48  private:
49     Msg_Thread_Queue_List *m_list;
50 };
51
52 class Msg_Thread : public yazpp_1::ISocketObserver {
53     class Private;
54  public:
55     Msg_Thread(yazpp_1::ISocketObservable *obs, int no_threads);
56     virtual ~Msg_Thread();
57     void socketNotify(int event);
58     void put(IMsg_Thread *m);
59     IMsg_Thread *get();
60     void run(void *p);
61 private:
62     class Private *m_p;
63 };
64
65 /*
66  * Local variables:
67  * c-basic-offset: 4
68  * indent-tabs-mode: nil
69  * End:
70  * vim: shiftwidth=4 tabstop=8 expandtab
71  */
72