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

[Libevent-users] Better support for user-triggered events



Figured I'd copy the list on an email I sent Nick about user-triggered events in case anyone else wanted to chime in (or contribute a patch!).

-Philip

To: Nick Mathewson <nickm@xxxxxxxxxxxx>
From: Philp Prindeville <philipp@xxxxxxxxxxxxxxxxxxxxx>
Subject: Question about libevent documentation
Message-ID: <8ba6e993-e887-983e-f06e-b88dfc3aac94@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 11 Sep 2016 11:18:40 -0600

Hi.

Thanks for providing this document.  It's been really helpful. However,
I'm looking at:

http://www.wangafu.net/~nickm/libevent-book/Ref4_event.html

where it says:


     Working with events

     Libevent's basic unit of operation is the event. Every event
     represents a set of conditions, including:

       * A file descriptor being ready to read from or write to.

       * A file descriptor becoming ready to read from or write to
         (Edge-triggered IO only).

       * A timeout expiring.

       * A signal occurring.

       * A user-triggered event.

but there's no description of user-triggered events.  I'm working with
some overly complicated legacy pthreaded code (which uses DBus) and I'm
trying to convert it piecemeal (since my boss doesn't want to allocate
the time to a big-bang re-write) to be event-driven.

Problem is that there are certain events which I need to be able to
model (like queues becoming empty/non-empty/full) and these will need to
be "user-triggered" events, but I can't see from the documentation how
to do this that fits well with our requirements:

I looked for some documentation elsewhere how to do this and saw your
stackoverflow posting:

http://stackoverflow.com/questions/7645217/user-triggered-event-in-libevent

but nothing that's "clean" comes up (either using an unneeded timer
interval, or else using undocumented functions which might change/go
away in the future).

Any chance of adding a couple of paragraphs on the best way to do this?

And it would be nice if the event could be added to the loop via
event_add(), and that the handler for that event was subject to the same
constraints (like priorities, max-dispatch interval, debugging with
event_base_dump_events(), etc).  Also, if you're doing profiling, then
you don't want the event that's setting the user-trigger to be "charged"
the time it takes the user-triggered event to run in addition to its own
time... it's misleading.

Lastly, you might have several high-priority events that run quickly and
want to "fire" the user-triggered event, but not actually have it run
until low-priority events can be dispatched... and then only once (i.e.
once per event-base loop dispatching iteration).

What do you think?

Thanks,

-Philip

P.S. I might be sending you a patch to bind a source address to a
bufferevent socket...

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