Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第三章-异步IO P63 页 next_tick_set_immediate.js 书中执行结果错误 #16

Closed
YOLO0927 opened this issue Mar 25, 2018 · 2 comments

Comments

@YOLO0927
Copy link

书中书写的输出结果为

正确执行
nextTick延迟执行1
nextTick延迟执行2
setImmediate延迟执行1
强势插入
setImmediate延迟执行2

正确结果应为在macro task setImmediate 队列下的主函数都执行完毕后才调用 micro task 的 process.nextTick 吧

正确执行
nextTick延迟执行1
nextTick延迟执行2
setImmediate延迟执行1
setImmediate延迟执行2
强势插入

附图

书中图
自己的执行结果

@JacksonTian
Copy link
Owner

书上这个错误是因为在 0.12 还是什么版本的时候,process.nextTick 和 setImmediate 底层更改了实现。因为这个地方的勘误会引起很大篇幅的改动,所以没有做,留到第二版再做把。

@YOLO0927
Copy link
Author

了解~谢谢朴老师的解答。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants