The method EventsLoop::interrupt() is currently serving the dual purpose of
- Stop processing events during
run_forever and poll_events
- Wakeup the event loop from other threads
Running the wakeup code when you only care about 1. simply wastes cycles.
I'm proposing that a second method, EventsLoop::wakeup() is added to allow performing these tasks independently. An alternative design would be removing the interrupted flag altogether and allow the closure passed to run_forever and poll_events to return a flag indicating their desire to continue or halt.
The method
EventsLoop::interrupt()is currently serving the dual purpose ofrun_foreverandpoll_eventsRunning the wakeup code when you only care about 1. simply wastes cycles.
I'm proposing that a second method,
EventsLoop::wakeup()is added to allow performing these tasks independently. An alternative design would be removing theinterruptedflag altogether and allow the closure passed torun_foreverandpoll_eventsto return a flag indicating their desire to continue or halt.