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

Re: [Libevent-users] Event priorities



OoO En  ce dÃbut  de soirÃe du  lundi 30  avril 2012, vers  21:53, Ralph
Castain <rhc@xxxxxxxxxxxx> disaitÂ:

> I'm working with priorities in events using libevent 2.0.13. Since I'm
> not using the most current release, I thought I'd ask about a behavior
> we are seeing that might be a potential bug.

> I have attached a simple reproducer of the problem. In short, suppose
> I have setup 8 priorities for my event base. I then execute an event
> at priority 4. In that callback, I setup and activate two new events -
> first one at priority 4, and then another at priority 0. We then cycle
> back through the event loop.

> Given the prioritized event base, I would expect the event at priority
> 0 to be called back first. However, this isn't what happens. Instead,
> the first event to be defined (in this case, the one at priority 4) is
> called back first.

> Is this the expected behavior? Can someone point me to the error in
> this reproducer that might be causing the problem?

I'd  say it  is the  expected behaviour.  Once you  exit  your callback,
libevent will look for the next  event in the current priority queue and
it is the one you have  just activated, so it calls its callback without
checking for other  proprities.

Latest libevent  2.1.x alpha introduced the following  function that may
suit your need:

http://www.wangafu.net/~nickm/libevent-2.1/doxygen/html/event_8h.html#a4ce79ea64f2fb7074487672801a1ad20

If  you call  `event_config_set_max_dispatch_interval()` with  the third
parameter set to 1, you will get the expected behaviour.
-- 
Vincent Bernat â http://vincent.bernat.im

# Okay, what on Earth is this one supposed to be used for?
        2.4.0 linux/drivers/char/cp437.uni
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.