From bc56a4e05c9d4ea7fd8b2e4a8b148395fc3166e2 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Wed, 29 May 2013 22:50:59 +0200 Subject: [PATCH] windows: call idle handles on every loop iteration This mimicks what the unix implementation does: call idle handles on every loop iteration. The guarantee that it runs on every loop iteration makes it easier to predict and opens up more use cases. Note that the name uv_idle is now a bit of a misnomer. There is actually no guarantee that libuv completely processed all i/o when an iteration ends. The windows implementation at least limits the amount of callbacks processed in a single iteration to avoid some handles getting a disproportionate amount of cpu attention. --- src/win/core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/win/core.c b/src/win/core.c index 3ba32038..0cf1bbbb 100644 --- a/src/win/core.c +++ b/src/win/core.c @@ -282,15 +282,11 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) { uv_update_time(loop); uv_process_timers(loop); - /* Call idle callbacks if nothing to do. */ - if (loop->pending_reqs_tail == NULL && - loop->endgame_handles == NULL) { - uv_idle_invoke(loop); - } - uv_process_reqs(loop); uv_process_endgames(loop); + uv_idle_invoke(loop); + uv_prepare_invoke(loop); (*poll)(loop, loop->idle_handles == NULL &&