#35 Daemon events that don't keep the event_loop from finishing

API
open
nobody
General (24)
5
2009-11-14
2009-11-14
Nick Mathewson
No

In lots of our unit tests, we want to run the event loop until a certain number of operations are finished. To do this, we count how many are finished, and call event_base_loopexit() when they're done.

Mostly we have to do this because there is some server port that listens for connection attempts, and even when all the test connections are finished, the server event is still listening.

A more elegant solution would be to label some events as "daemon" events. These would share the property with internal events that they do not keep the event_loop from exiting if all the other events are done. The nomenclature is taken from threading libraries that provide a similar feature where the process exits as soon as all non-daemon threads are done running.

Discussion

  • Nick Mathewson
    Nick Mathewson
    2010-12-01

    Another solution here would be an event_base_loop() flag that tells Libevent to keep waiting even if there are no non-internal events.