1 /* This file is part of YAZ proxy
2 Copyright (C) 1998-2011 Index Data
4 YAZ proxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <yazpp/pdu-assoc.h>
23 #include <yazpp/socket-manager.h>
25 #include "msg-thread.h"
31 using namespace yazpp_1;
33 class My_Msg : public IMsg_Thread {
35 IMsg_Thread *handle();
40 IMsg_Thread *My_Msg::handle()
42 My_Msg *res = new My_Msg;
46 printf("My_Msg::handle val=%d sleep=%d\n", m_val, sl);
55 printf("My_Msg::result val=%d\n", m_val);
58 class My_Timer_Thread : public ISocketObserver {
60 ISocketObservable *m_obs;
64 My_Timer_Thread(ISocketObservable *obs, Msg_Thread *t);
65 void socketNotify(int event);
68 My_Timer_Thread::My_Timer_Thread(ISocketObservable *obs,
69 Msg_Thread *t) : m_obs(obs)
73 obs->addObserver(m_fd[0], this);
74 obs->maskObserver(this, SOCKET_OBSERVE_READ);
75 obs->timeoutObserver(this, 1);
78 void My_Timer_Thread::socketNotify(int event)
81 printf("Add %d\n", seq);
82 My_Msg *m = new My_Msg;
87 int main(int argc, char **argv)
89 SocketManager mySocketManager;
91 Msg_Thread m(&mySocketManager, 3);
92 My_Timer_Thread t(&mySocketManager, &m) ;
94 while (++i < 5 && mySocketManager.processEvent() > 0)
101 * c-file-style: "Stroustrup"
102 * indent-tabs-mode: nil
104 * vim: shiftwidth=4 tabstop=8 expandtab