src: don't run timers before entering event loop (#4026)
There should be no need to run timers prior to entering the event loop. Instead allow them to run normally at the end after the poll phase is complete. Ref: https://github.com/libuv/libuv/pull/3927 Ref: https://github.com/libuv/libuv/issues/4017
This commit is contained in:
parent
4e774df4cc
commit
00357f8732
@ -62,9 +62,6 @@ stages of a loop iteration:
|
||||
|
||||
#. The loop concept of 'now' is initially set.
|
||||
|
||||
#. Due timers are run if the loop was run with ``UV_RUN_DEFAULT``. All active timers scheduled
|
||||
for a time before the loop's concept of *now* get their callbacks called.
|
||||
|
||||
#. If the loop is *alive* an iteration is started, otherwise the loop will exit immediately. So,
|
||||
when is a loop considered to be *alive*? If a loop has active and ref'd handles, active
|
||||
requests or closing handles it's considered to be *alive*.
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 61 KiB |
@ -411,16 +411,6 @@ int uv_run(uv_loop_t* loop, uv_run_mode mode) {
|
||||
if (!r)
|
||||
uv__update_time(loop);
|
||||
|
||||
/* Maintain backwards compatibility by processing timers before entering the
|
||||
* while loop for UV_RUN_DEFAULT. Otherwise timers only need to be executed
|
||||
* once, which should be done after polling in order to maintain proper
|
||||
* execution order of the conceptual event loop. */
|
||||
if (mode == UV_RUN_DEFAULT) {
|
||||
if (r)
|
||||
uv__update_time(loop);
|
||||
uv__run_timers(loop);
|
||||
}
|
||||
|
||||
while (r != 0 && loop->stop_flag == 0) {
|
||||
can_sleep =
|
||||
QUEUE_EMPTY(&loop->pending_queue) && QUEUE_EMPTY(&loop->idle_handles);
|
||||
|
||||
@ -497,16 +497,6 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) {
|
||||
if (!r)
|
||||
uv_update_time(loop);
|
||||
|
||||
/* Maintain backwards compatibility by processing timers before entering the
|
||||
* while loop for UV_RUN_DEFAULT. Otherwise timers only need to be executed
|
||||
* once, which should be done after polling in order to maintain proper
|
||||
* execution order of the conceptual event loop. */
|
||||
if (mode == UV_RUN_DEFAULT) {
|
||||
if (r)
|
||||
uv_update_time(loop);
|
||||
uv__run_timers(loop);
|
||||
}
|
||||
|
||||
while (r != 0 && loop->stop_flag == 0) {
|
||||
can_sleep = loop->pending_reqs_tail == NULL && QUEUE_EMPTY(&loop->idle_handles);
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ static void close_cb(uv_handle_t* handle) {
|
||||
/* check_cb should run before any close_cb */
|
||||
static void check_cb(uv_check_t* handle) {
|
||||
ASSERT(check_cb_called == 0);
|
||||
ASSERT(timer_cb_called == 1);
|
||||
ASSERT(timer_cb_called == 0);
|
||||
ASSERT(close_cb_called == 0);
|
||||
uv_close((uv_handle_t*) handle, close_cb);
|
||||
uv_close((uv_handle_t*) &timer_handle2, close_cb);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user