Questions regarding how libev works

Cong yuncong at gmail.com
Thu Mar 8 21:15:30 CET 2012


Hi,

If I don't use multi-threading, do I need to stop accept watcher whenever a
connection is accepted? I don't stop accept watcher in my code currently,
and it works fine. But I cannot explain how the accept watcher works. If
there're multiple connection requests received, the accept callback
function will create a new socket and start a read watcher for each of
them. Seems to me this works as if there're multiple "threads", although
they're not real threads. All these sockets are polled quickly in a loop to
see if there's any incoming connection, if anyone is readable and if anyone
is writable. Is my understanding correct?

Seems introducing threads can only add overhead but not benefits. However,
on a multi-core computer, if the program is not multi-threaded, can the OS
use multi-core to improve the performance?

Thanks,
Cong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20120308/3ec8da1f/attachment.html>


More information about the libev mailing list