ev_async delays thread when joining

Juan Pablo L jpablolorenzetti at gmail.com
Sun Jan 2 04:09:36 CET 2011


thank you very much for your feedback, the futex call is a call inside the
epoll, anyways, in other words, you are saying that, for example,
if i create a loop in thread 1 and i want to break it and destroy it or even
stop the ev_async in thread 2 is not allowed ? i need to do a explicit loop
locking in thread 2 ?
so from thread 2 i can only call ev_async_send and the rest of calls
regarding the loop must be made inside thread 1 without locking (if i dont
want to lock the loop) ?? thanks!


On 1 January 2011 22:47, Marc Lehmann <schmorp at schmorp.de> wrote:

> On Sat, Jan 01, 2011 at 08:10:30PM -0400, Juan Pablo L <
> jpablolorenzetti at gmail.com> wrote:
> > Hi, i m new to libev and i m trying to use ev_async to signal some
> threads
> > for some events, everything is ok but when the threads end
> > they take very long to be joined, like in minutes which makes the
> > application not responsive (i need them to be joinable in the real
> > application), i m sure the problem is with ev_async,
> > i have tested without it and with it, the problem is the ev_async but i
> have
> > no idea where the problem is, doing strace it shows that the loop gets
> stack
> > at epoll in a futex call,
>
> libev doesn't do any futex calls, so if it gets stuck in one, it means it'S
> in somebody elses code.
>
> > void *the_thread_function(struct ev_loop *evt_loop)
> > {
> >         ev_run(evt_loop,0);
> >         pthread_exit(NULL);
> > }
>
> this is one thread.
>
> >         while(--i >= 0)
> >         {
> >                 printf("i = %d\n",i);
> >                 ev_async_send(evt_loop,&as_evt);
> >                 sleep(1);
> >         }
> >
> >         ev_break(evt_loop,EVBREAK_ALL);
> >
> >         printf("stopping watcher\n");
> >         ev_async_stop(evt_loop,&as_evt);
>
> and this is another. I don't see you locking the loop, so this is the first
> thing you need to fix: the only call allowed on an event loop used in
> another
> thread is ev_async_send, no other calls may be done.
>
> if you want to join the thread, you could make the thread
> cancelable/uncanceble via ev_set_loop_release_cb, and just cancel it.
>
> or you could pthread_exit in the async watcher callback, and
> ev_async_send, then join.
>
> --
>                The choice of a       Deliantra, the free code+content MORPG
>      -----==-     _GNU_              http://www.deliantra.net
>      ----==-- _       generation
>      ---==---(_)__  __ ____  __      Marc Lehmann
>      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
>      -=====/_/_//_/\_,_/ /_/\_\
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20110101/b895e404/attachment.html>


More information about the libev mailing list