Actually event_set() caused segmentation fault, but it's newer substitution
- event_assign() works perfectly. Problem solved. Thank you both for help.
2011/4/7 JiangHao
> sorry ,i read your question again .
> may be we could do this:
> event* ev = event_new(0, -1,0, 0,0);
> event_set(ev,base, so
sorry ,i read your question again .
may be we could do this:
event* ev = event_new(0, -1,0, 0,0);
event_set(ev,base, socket, flags, cb_func, ev);
then you could pass the event as argument .
2011/4/7 Michał Król
> Hi,
>
> I was wondering if there is any way I can access event object within
> cal
@蒋浩It doesn't matter weather I'll add or delete event, but I need event
struct for both operations.
@song
Yes I think it'll do what I want. I thought that maybe there is a bit
simpler method, but this is solution is good enough - thanks a lot!
Michal
2011/4/7 蒋浩
> hi,you could do like this:
>
hi,you could do like this:
set event type without EV_PERSISTENT
void cb_func(int fd,short types,void* arg)
{
//do some work
if (cond==false)
{
event_add(event);//will be triggered again.
}
}
2011/4/7 Michał Król
> Hi!
>
> Thanks for your response. Unfortunately I want to invoke thi
why not replace the following struct with args?
typedef struct {
struct event *evt;
void *otherargs;
} Parameter;
Parameter *p = malloc(xx)
evt = event_new(xxx, p);
p->evt = evt;
...
-Song
On , Michał Król wrote:
Hi!
Thanks for your response. Unfortunately I want to invoke this event more
Hi!
Thanks for your response. Unfortunately I want to invoke this event more
then once, and stop invoking after particular condition occurs, so it's more
like:
void cb_func(agrs){
//do some work
if(cond)
event_del(event);
}
2011/4/7 蒋浩
> hi,maybe you call event_new without
hi,maybe you call event_new without the flag of EV_PERSISTENT,so when
cb_func is triggered ,the event is automatic deleted by event_base_loop,it's
seems there is two ev_del calls in your example ,
forgive my pool english..
2011/4/7 Michał Król
> Hi,
>
> I was wondering if there is any way I ca
Hi,
I was wondering if there is any way I can access event object within
callback function in libevent2? I know I can put it in global variable, but
I'll have a lot of events and I want to access particular one, so I want to
avoid it.
I cannot pass it as an argument because I'll have pointer to e