ev_async watcher's callback is never triggering on ev_async_send()
trafdev
trafdev at mail.ru
Sat Jun 29 23:50:37 CEST 2013
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!
More information about the libev
mailing list