Comments inline.. On Mon, Feb 26, 2007 at 11:57:55PM +0100, Christian Ress wrote: > 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;
allocate your event struct in the callback as the storage will disapear. > evtimer_set(&newev, second_cb, NULL); > event_base_set(ev_base, &newev); > event_add(&newev, &tv); > > event_base_dispatch(ev_base); no need to re-run the dispatch call here as the one in main() is the main loop and will pick up after the return of the callback. > } > > 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. as stated above.. there is no need to call event_base_dispatch() again, so there wont be a problem. If you really need to go through one pass then use event_loop()/event_base_loop() -Phil. _______________________________________________ Libevent-users mailing list Libevent-users@monkey.org http://monkey.org/mailman/listinfo/libevent-users