[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] can I call event_del() on an event and then use event_add to add it again?



I register an timeout event as below:

struct event * fin_ev = (struct event *)malloc(sizeof(struct event));
event_set(fin_ev, -1, 0, on_fin_timeout, NULL);
event_base_set(base, fin_ev);
event_add(fin_ev, &tv) ;

and when a condition is satisfied when the timeout event is not triggered, I want to remove the event and add it againÂ

can I do something like:
 ÂÂ
   Âif(condition){
     Âevent_del(fin_ev);
     Âevent_add(fin_ev, &tv) Â
   }

orÂ

   Âif(condition){
     event_set(fin_ev, -1, 0, on_fin_timeout, NULL);
     event_base_set(base, fin_ev);
     Âevent_del(fin_ev);
     Âevent_add(fin_ev, &tv) Â
   }

?