Re: Simplest threaded example

2010-08-03 Thread Marc Lehmann
On Tue, Aug 03, 2010 at 01:38:33PM +0200, Hongli Lai wrote: > Well I see that you're using the same event loop in all worker > threads. That's obviously not gonna work. It is as long as he locks. In fact, this is a common pattern in threaded design called leader-follower, where one thread runs t

Re: Simplest threaded example

2010-08-03 Thread Hongli Lai
Well I see that you're using the same event loop in all worker threads. That's obviously not gonna work. What you could do for example is to accept() connections from the main thread, and for each accepted connection spawn a worker thread that handles that connection only. Each worker thread must

Re: Simplest threaded example

2010-07-29 Thread Marc Lehmann
On Thu, Jul 29, 2010 at 11:28:46AM +0900, Horacio Sanson wrote: > After reading several times the documentation/mailing list this is the > simplest > threading model I found to work with libev (C++): Really? simplest? > ev::io m_stdinWatcher; > ev::sig m_sigintWatcher; > ev::sig m_

Simplest threaded example

2010-07-28 Thread Horacio Sanson
After reading several times the documentation/mailing list this is the simplest threading model I found to work with libev (C++): #define EV_STANDALONE 1 #define EV_FEATURES 8 #define EV_USE_EPOLL 1 #define EV_PREPARE_ENABLE 1 #define EV_IDLE_ENABLE 1 #define EV_SIGNAL_ENABLE 1 #define EV_CHILD_EN