libev out of context thread
Marc Lehmann
schmorp at schmorp.de
Wed Dec 11 09:31:51 CET 2013
On Wed, Dec 11, 2013 at 01:11:02PM +1100, Varun Chandramohan <cvaruneng04 at gmail.com> 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
--==---/ / _ \/ // /\ \/ / schmorp at schmorp.de
-=====/_/_//_/\_,_/ /_/\_\
More information about the libev
mailing list