Create a better-designed system for handling computation outside the event loop
Right now, we do a couple of things in
run_main_loop_once that happen outside the event loop (because we want to re-scan for events event loop before they happen):
- Making events on active_linked_connection_lst active.
- Running connection_ap_attach_pending.
But we can do this much better. With Libevent 2.1, instead of making the loop exit for this, we can should do all of these things in a separate event callback, and call
event_base_loopcontinue() at the end of that event's callback so that the event_base will get rescanned before we return. With earlier versions of Libevent, we can do something similar with event_base_loopbreak().
Doing this won't lower the number of wakeups we do, but it should simplify our overall event loop logic, and make other event loop simplifications easier.