Hi Marc, Thanks for the reply. Not sure why the code formatting is weird. I started using async watchers and it helped. I got it working with that. I did remove one other thread as I felt it was not needed with async watcher. My solution is to use thread 1 to read from socket a packet add it to queue and immediately notify the async watcher of data available. I also added mutex lock to avoid race condition. Everything seem to be working well as expected. I have currently put the code under stress test. Thanks for the help.
Regards, Varun On Wed, Dec 11, 2013 at 7:31 PM, Marc Lehmann <[email protected]> wrote: > On Wed, Dec 11, 2013 at 01:11:02PM +1100, Varun Chandramohan < > [email protected]> wrote: > > Once I have a sd to add to loop can I call > > > > ev_io_init(&d_packet->io, connect_ps_cb, d_packet->connect_sd, > EV_WRITE| > > EV_READ); > > Funny code formatting in your e-mail. > > Anyways, if I understand your mail correctly, you want to add watchers to a > loop running in another thread. > > That's fine, as long as you lock the loop (just like your array) with a > mutex or so. See the thread locking example in the manpage. You can use an > async watcher to wake up the loop after you changed it. > > Whether overall ti is a good approach I can't tell from your mail, but > adding threads rarely make things better, they do make things much more > complex and error prone usually. > > -- > The choice of a Deliantra, the free code+content > MORPG > -----==- _GNU_ http://www.deliantra.net > ----==-- _ generation > ---==---(_)__ __ ____ __ Marc Lehmann > --==---/ / _ \/ // /\ \/ / [email protected] > -=====/_/_//_/\_,_/ /_/\_\ >
_______________________________________________ libev mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
