1 /* $Id: tstthreads.cpp,v 1.11 2006-03-30 14:19:19 adam Exp $
2 Copyright (c) 1998-2006, Index Data.
4 This file is part of the yazproxy.
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 <yazpp/pdu-assoc.h>
26 #include <yazpp/socket-manager.h>
28 #include "msg-thread.h"
34 using namespace yazpp_1;
36 class My_Msg : public IMsg_Thread {
38 IMsg_Thread *handle();
43 IMsg_Thread *My_Msg::handle()
45 My_Msg *res = new My_Msg;
49 printf("My_Msg::handle val=%d sleep=%d\n", m_val, sl);
58 printf("My_Msg::result val=%d\n", m_val);
61 class My_Timer_Thread : public ISocketObserver {
63 ISocketObservable *m_obs;
67 My_Timer_Thread(ISocketObservable *obs, Msg_Thread *t);
68 void socketNotify(int event);
71 My_Timer_Thread::My_Timer_Thread(ISocketObservable *obs,
72 Msg_Thread *t) : m_obs(obs)
76 obs->addObserver(m_fd[0], this);
77 obs->maskObserver(this, SOCKET_OBSERVE_READ);
78 obs->timeoutObserver(this, 1);
81 void My_Timer_Thread::socketNotify(int event)
84 printf("Add %d\n", seq);
85 My_Msg *m = new My_Msg;
90 int main(int argc, char **argv)
92 SocketManager mySocketManager;
94 Msg_Thread m(&mySocketManager, 3);
95 My_Timer_Thread t(&mySocketManager, &m) ;
97 while (++i < 5 && mySocketManager.processEvent() > 0)
104 * indent-tabs-mode: nil
106 * vim: shiftwidth=4 tabstop=8 expandtab