1 /* $Id: tstthreads.cpp,v 1.3 2005-05-30 20:08:58 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 class My_Msg : public IMsg_Thread {
32 IMsg_Thread *handle();
37 IMsg_Thread *My_Msg::handle()
39 My_Msg *res = new My_Msg;
43 printf("My_Msg::handle val=%d sleep=%d\n", m_val, sl);
50 printf("My_Msg::result val=%d\n", m_val);
53 class My_Timer_Thread : public IYazSocketObserver {
55 IYazSocketObservable *m_obs;
59 My_Timer_Thread(IYazSocketObservable *obs, Msg_Thread *t);
60 void socketNotify(int event);
63 My_Timer_Thread::My_Timer_Thread(IYazSocketObservable *obs,
64 Msg_Thread *t) : m_obs(obs)
68 obs->addObserver(m_fd[0], this);
69 obs->maskObserver(this, YAZ_SOCKET_OBSERVE_READ);
70 obs->timeoutObserver(this, 2);
73 void My_Timer_Thread::socketNotify(int event)
76 printf("Add %d\n", seq);
77 My_Msg *m = new My_Msg;
82 int main(int argc, char **argv)
84 Yaz_SocketManager mySocketManager;
86 Msg_Thread m(&mySocketManager);
87 My_Timer_Thread t(&mySocketManager, &m) ;
89 while (++i < 5 && mySocketManager.processEvent() > 0)