worker threads to use (used to be one only).
-/* $Id: msg-thread.cpp,v 1.7 2005-08-15 12:51:57 adam Exp $
+/* $Id: msg-thread.cpp,v 1.8 2005-09-12 20:09:14 adam Exp $
Copyright (c) 1998-2005, Index Data.
This file is part of the yaz-proxy.
}
-Msg_Thread::Msg_Thread(ISocketObservable *obs)
+Msg_Thread::Msg_Thread(ISocketObservable *obs, int no_threads)
: m_SocketObservable(obs)
{
pipe(m_fd);
pthread_mutex_init(&m_mutex_input_data, 0);
pthread_cond_init(&m_cond_input_data, 0);
pthread_mutex_init(&m_mutex_output_data, 0);
- pthread_create(&m_thread_id, 0, tfunc, this);
+
+ m_no_threads = no_threads;
+ m_thread_id = new pthread_t[no_threads];
+ int i;
+ for (i = 0; i<m_no_threads; i++)
+ pthread_create(&m_thread_id[i], 0, tfunc, this);
}
Msg_Thread::~Msg_Thread()
pthread_cond_signal(&m_cond_input_data);
pthread_mutex_unlock(&m_mutex_input_data);
- pthread_join(m_thread_id, 0);
+ int i;
+ for (i = 0; i<m_no_threads; i++)
+ pthread_join(m_thread_id[i], 0);
+ delete [] m_thread_id;
m_SocketObservable->deleteObserver(this);
-/* $Id: msg-thread.h,v 1.5 2005-08-15 12:51:57 adam Exp $
+/* $Id: msg-thread.h,v 1.6 2005-09-12 20:09:14 adam Exp $
Copyright (c) 1998-2005, Index Data.
This file is part of the yaz-proxy.
class Msg_Thread : public yazpp_1::ISocketObserver {
public:
- Msg_Thread(yazpp_1::ISocketObservable *obs);
+ Msg_Thread(yazpp_1::ISocketObservable *obs, int no_threads);
virtual ~Msg_Thread();
void socketNotify(int event);
void put(IMsg_Thread *m);
int m_fd[2];
private:
yazpp_1::ISocketObservable *m_SocketObservable;
- pthread_t m_thread_id;
+ int m_no_threads;
+ pthread_t *m_thread_id;
Msg_Thread_Queue m_input;
Msg_Thread_Queue m_output;
pthread_mutex_t m_mutex_input_data;
* Copyright (c) 1998-2005, Index Data.
* See the file LICENSE for details.
*
- * $Id: t-server.cpp,v 1.3 2005-09-11 20:06:54 adam Exp $
+ * $Id: t-server.cpp,v 1.4 2005-09-12 20:09:14 adam Exp $
*/
#include <stdlib.h>
int ret;
const char *addr = "tcp:@:9999";
char *apdu_log = 0;
+ int no_threads = 1;
- while ((ret = options("a:v:T", argv, argc, &arg)) != -2)
+ while ((ret = options("n:a:v:T", argv, argc, &arg)) != -2)
{
switch (ret)
{
case 0:
addr = xstrdup(arg);
break;
+ case 'n':
+ no_threads = atoi(arg);
+ break;
case 'a':
apdu_log = xstrdup(arg);
break;
MyServer *z = 0;
- Msg_Thread *my_thread = new Msg_Thread(&mySocketManager);
+ Msg_Thread *my_thread = new Msg_Thread(&mySocketManager, no_threads);
#if YAZ_POSIX_THREADS
if (thread_flag)
-/* $Id: tstthreads.cpp,v 1.6 2005-06-25 15:58:33 adam Exp $
+/* $Id: tstthreads.cpp,v 1.7 2005-09-12 20:09:14 adam Exp $
Copyright (c) 1998-2005, Index Data.
This file is part of the yaz-proxy.
{
SocketManager mySocketManager;
- Msg_Thread m(&mySocketManager);
+ Msg_Thread m(&mySocketManager, 1);
My_Timer_Thread t(&mySocketManager, &m) ;
int i = 0;
while (++i < 5 && mySocketManager.processEvent() > 0)
-/* $Id: yaz-proxy.cpp,v 1.35 2005-08-15 12:53:08 adam Exp $
+/* $Id: yaz-proxy.cpp,v 1.36 2005-09-12 20:09:14 adam Exp $
Copyright (c) 1998-2005, Index Data.
This file is part of the yaz-proxy.
m_proxy_negotiation_lang);
// create thread object the first time we get an incoming connection
if (!m_my_thread)
- m_my_thread = new Msg_Thread(m_socket_observable);
+ m_my_thread = new Msg_Thread(m_socket_observable, 1);
new_proxy->m_my_thread = m_my_thread;
return new_proxy;
}