could anyone tell me about how to exit the program using libev

Marc Lehmann schmorp at
Thu Jun 28 13:32:29 CEST 2012

On Thu, Jun 28, 2012 at 06:52:08PM +0800, debuguo <wateraworld at> wrote:
> In start() function, I called ev_loop_new() to create some loops, then
> created some threads in which ev_run() each loop.
> In stop() function, I called ev_break() to stop each loop, then
> ev_loop_destroy to release resources.
> And I WRONG?

Yes, when accessing a shared resource from multiple threads, you'd have to
use some kind of locking or other synchronsiation.

You can create async watchers for those loops that call ev_break, and then
use ev_async_send from your stop function.

You might also question the use of threads - threads are definitely very
complex beasts, and maybe libev is not the best library to learn your way
around threads.

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_    
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list