[Libevent-users] multiple calls of event_dispatch()

Christian Ress christian at yetisoft.org
Mon Feb 26 17:57:55 EST 2007


Hello,

I stumbled across libevent and it seems to fit my needs very well.
However, I wonder if this is side-effect free:

second_cb(..) { .. }
first_cb(..) {
   ..
   struct event newev;
   evtimer_set(&newev, second_cb, NULL);
   event_base_set(ev_base, &newev);
   event_add(&newev, &tv);

   event_base_dispatch(ev_base);
}

main() {
   ..
   ev_base = event_init();
   evtimer_set(ev, first_cb, NULL);
   event_add(ev, &tv);

   event_base_dispatch(ev_base);
}

The point of this is creating new events 'on demand', but since I'm 
calling event_dispatch when being called by event_loop, I wonder if this 
might lead to recursion issues or similar bad behaviour.

I hope someone can clarify this :)

Thanks,
Christian




More information about the Libevent-users mailing list