ev_async watcher's callback is never triggering on ev_async_send()
马承珂
fatmck at 163.com
Sun Jun 30 02:27:51 CEST 2013
line 25:
ev_async_send (dyn_loop, &mysig);
should be:
ev_async_send (dyn_loop, &async_w);
mysig is a useless var.
At 2013-06-30 05:50:37,trafdev <trafdev at mail.ru> wrote:
>Hello.
>
>Simple code:
>
>#include <ev.h>
>#include <stdio.h>
>#include <pthread.h>
>
>static void async_cb (EV_P_ ev_async *w, int revents) {
> printf("never got called :(\n");
> return;
>}
>
>static ev_async async_w;
>
>static struct ev_loop* dyn_loop;
>
>void* thread_loop(void* args) {
> dyn_loop = ev_loop_new(0);
> ev_async_init(&async_w, async_cb);
> ev_async_start(dyn_loop, &async_w);
> ev_run(dyn_loop);
> int a = 0;
>}
>
>static ev_async mysig;
>
>static void timeout_cb(EV_P_ ev_timer *w, int revents) {
> ev_async_send (dyn_loop, &mysig);
>}
>
>struct ev_loop* loop = ev_default_loop(0);
>
>int main(int argc, char **argv) {
> pthread_t thread;
> pthread_create(&thread, NULL, thread_loop, NULL);
>
> static ev_timer tw;
> ev_timer_init (&tw, timeout_cb, 5, 3);
> ev_timer_start(loop, &tw);
>
> ev_run(loop, 0);
>
> return 0;
>}
>
>
>Should cause async_cb triggering from timeout_cb, but this never happens
>(timout_cb is triggering without problems).
>Tried many combinations (like creating dyn_loop in main thread etc - no
>effect). Please help!
>
>_______________________________________________
>libev mailing list
>libev at lists.schmorp.de
>http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20130630/cba22e52/attachment.html>
More information about the libev
mailing list