Discussion:
fd=-1 events
(too old to reply)
Александр Смирнов
2014-01-10 21:24:42 UTC
Permalink
Raw Message
Greetings!

Thanks in advance for any help you are able to provide! I'm on my very
start with libevent.

As far as I understand libevent will instantly notify me about any event on
file descriptor.

But what with events which has no file descriptor (fd = -1) ?

Do I understand right that in blocking mode event_base_loop() will block
only on real events (based on existing fds) ? So event_active() will not
have any effect until some real event triggered ?

What I've managed to find out by myself:
* event_active() does nothing beside placing event on queue to process. so
it not assumes "immediate" action.
* event_add calls evmap_io_add which does nothing in case of fd<0

So there is no way to get immediate response for fd=-1 events ?

Best regards, Alexander Smirnov
Nick Mathewson
2014-01-13 04:43:54 UTC
Permalink
Raw Message
Post by Александр Смирнов
Greetings!
Thanks in advance for any help you are able to provide! I'm on my very start
with libevent.
As far as I understand libevent will instantly notify me about any event on
file descriptor.
But what with events which has no file descriptor (fd = -1) ?
Do I understand right that in blocking mode event_base_loop() will block
only on real events (based on existing fds) ? So event_active() will not
have any effect until some real event triggered ?
* event_active() does nothing beside placing event on queue to process. so
it not assumes "immediate" action.
* event_add calls evmap_io_add which does nothing in case of fd<0
So there is no way to get immediate response for fd=-1 events ?
fd==-1 is used in libevent to indicate an event that has no fd --
either because it is a timer-only event, or because it's used only
with event_active(). It should not have EV_READ or EV_WRITE set.

In general, libevent doesn't have a good notion of "run immediately"
-- the closest that it has is "run this event as part of processing
active events" -- which causes the event to get invoked right away if
the event loop is running, but not otherwise.
***********************************************************************
To unsubscribe, send an e-mail to ***@freehaven.net with
unsubscribe libevent-users in the body.
Alexander Smirnov
2014-01-13 08:21:21 UTC
Permalink
Raw Message
Thank you, Nick.

Is it possible to achieve immediate action by using pipes ? Are they supported ?
Post by Nick Mathewson
Post by Александр Смирнов
Greetings!
Thanks in advance for any help you are able to provide! I'm on my very start
with libevent.
As far as I understand libevent will instantly notify me about any event on
file descriptor.
But what with events which has no file descriptor (fd = -1) ?
Do I understand right that in blocking mode event_base_loop() will block
only on real events (based on existing fds) ? So event_active() will not
have any effect until some real event triggered ?
* event_active() does nothing beside placing event on queue to process. so
it not assumes "immediate" action.
* event_add calls evmap_io_add which does nothing in case of fd<0
So there is no way to get immediate response for fd=-1 events ?
fd==-1 is used in libevent to indicate an event that has no fd --
either because it is a timer-only event, or because it's used only
with event_active(). It should not have EV_READ or EV_WRITE set.
In general, libevent doesn't have a good notion of "run immediately"
-- the closest that it has is "run this event as part of processing
active events" -- which causes the event to get invoked right away if
the event loop is running, but not otherwise.
***********************************************************************
unsubscribe libevent-users in the body.
***********************************************************************
To unsubscribe, send an e-mail to ***@freehaven.net with
unsubscribe libevent-users in the body.

Loading...