Return from uev_run() when UEV_NONBLOCK and no event is pending

uev_run() with only UEV_NONBLOCK never returns when there are watchers
but no events, it spins at full CPU load:

    uev_run(ctx, UEV_NONBLOCK);

The loop polls epoll with a zero timeout and only stops on UEV_ONCE.

Leave the loop when a nonblocking poll finds no events.
This commit is contained in:
NefelibateLG authored and Joachim Wiberg committed 2026-11-16 15:08:42 +01:00
1 parent 09d9b6ba04
commit 28643fa599
5 files changed
+45 -5

No files matched your search

+2 -2
View File
@@ -168,8 +168,8 @@ result = uev_run(&ctx, UEV_NONE);
```
With `flags` set to `UEV_ONCE` the event loop returns as soon as it has
served the first event. If `flags` is set to `UEV_ONCE | UEV_NONBLOCK`
the event loop returns immediately if no event is available.
served the first event. With `UEV_NONBLOCK` the event loop returns as
soon as no event is available, also when combined with `UEV_ONCE`.
Timers are started by the first call to `uev_run()` and keep their
deadline between calls. Use `uev_timer_set()` to restart a timer.