1455220
nodejs 去检查timers, poll等的event loop是怎么触发的,如果是轮询,时间间隔多少
nodejs 去检查timers, poll等的event loop是怎么触发的,如果是轮询,时间间隔多少
就是轮询事件。
当然不是
@i5ting 哈哈,我只看了libuv项目下面的一些文件,node.cc确实没看过 有时间好好研究下
@i5ting 这段代码是哪个文件下的?找半天没找到
@Yuki-Minakami 那个太靠后了
{
SealHandleScope seal(isolate);
bool more;
do {
v8_platform.PumpMessageLoop(isolate);
more = uv_run(env.event_loop(), UV_RUN_ONCE);
if (more == false) {
v8_platform.PumpMessageLoop(isolate);
EmitBeforeExit(&env);
// Emit `beforeExit` if the loop became alive either after emitting
// event, or after running some callbacks.
more = uv_loop_alive(env.event_loop());
if (uv_run(env.event_loop(), UV_RUN_NOWAIT) != 0)
more = true;
}
} while (more == true);
}
谢谢两位啊
是的,核心代码在libuv/src/unix/core.c 的uv_run方法里,你可以参考下
@dai1054067910 libuv里确实是while true,如果有事件就拿出来
类似于一个while true的循环,不断执行timers, I/o callback, poll等阶段吧
int epoll_wait(uv__os390_epoll* ep, struct epoll_event *events, int maxevents, int timeout);