1 /* $Id: tstthreads.cpp,v 1.5 2005-06-08 13:29:03 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
25 #include <yaz++/pdu-assoc.h>
26 #include <yaz++/socket-manager.h>
28 #include "msg-thread.h"
30 using namespace yazpp_1;
32 class My_Msg : public IMsg_Thread {
34 IMsg_Thread *handle();
39 IMsg_Thread *My_Msg::handle()
41 My_Msg *res = new My_Msg;
45 printf("My_Msg::handle val=%d sleep=%d\n", m_val, sl);
52 printf("My_Msg::result val=%d\n", m_val);
55 class My_Timer_Thread : public ISocketObserver {
57 ISocketObservable *m_obs;
61 My_Timer_Thread(ISocketObservable *obs, Msg_Thread *t);
62 void socketNotify(int event);
65 My_Timer_Thread::My_Timer_Thread(ISocketObservable *obs,
66 Msg_Thread *t) : m_obs(obs)
70 obs->addObserver(m_fd[0], this);
71 obs->maskObserver(this, SOCKET_OBSERVE_READ);
72 obs->timeoutObserver(this, 2);
75 void My_Timer_Thread::socketNotify(int event)
78 printf("Add %d\n", seq);
79 My_Msg *m = new My_Msg;
84 int main(int argc, char **argv)
86 SocketManager mySocketManager;
88 Msg_Thread m(&mySocketManager);
89 My_Timer_Thread t(&mySocketManager, &m) ;
91 while (++i < 5 && mySocketManager.processEvent() > 0)