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

Re: [Libevent-users] Callback user_data



On Fri, Aug 23, 2013 at 11:38 AM, Timir Karia <tkaria@xxxxxxxxx> wrote:
> Hey Nick - thanks for the quick reply.
>
> One more question (new to libevent so sorry if it's obvious).
>
> In normal pollfd I can add and remove events by |= and &= with appropriate
> flags but I'm looking for the libevent equivalent.
>
> I'm simply looking for a simple way in a single threaded program to add and
> remove events. But it seems that we need to:
> 1) check if the event is pending
> 2) event_get_assignment(..., &assigned_events, ...)
> 3) event_assign
>
> Is this correct or am I missing something.

Well, you must never call event_assign() on an event that has been
added with event_all() without first removing it with event_del().


What more applications tend to do is create separate event objects for
EV_READ and EV_WRITE, and then use event_add() and event_del() to
enable or disable them individually.

yrs,
-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.