On Thu, Jun 28, 2012 at 10:51 AM, debuguo <waterawo...@gmail.com> wrote:
> I just find that it seems not stopped when "ev_beak" has been called, even
> after "ev_loop_destroy".
> I have stop all the watchers in the loop, and called the ev_break() in one
> thread, and another thread(containing the ev_run) will still execute the
> ev_run and write callback.
> I don't know why and I want to exit the program properly.
> Thank you.

If you call ev_break, the event loop isn't stopped immediately, but
only at the end of the current event loop iteration.  Thus, any
watchers that have triggered in this iteration will still be invoked
after you call ev_break.  If you ev_stop a watcher, then its callback
will not be invoked though, so that can hasten exitting.

Do not call ev_loop_destroy while the loop is still running.  That's
just a bad idea.

If you want to stop the event loop immediately, you can longjmp (or do
some other non-local jump) outside the ev_run.  In that case, if you
would like to reclaim memory allocated by the loop, it's still your
task to stop all the watchers first, and then call ev_loop_destroy.

Ambrus

_______________________________________________
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to