简体   繁体   English

微任务如何使其进入微任务队列?

[英]How do Microtasks make it to the Microtask queue?

I'm currently researching the Javascript event loop, concurrency, micro/macro task queues. 我目前正在研究Javascript事件循环,并发,微/宏任务队列。

I see that when using setTimeout, the Browser's Web Api handles the timer and passes the callback on to the macrotask queue to be run by the call stack via the event loop. 我看到使用setTimeout时,浏览器的Web Api处理计时器并将回调传递给宏任务队列,以通过事件循环由调用堆栈运行。

However, in the case of a microtask, such as a Promise, is the Browser's Web Api also responsible for handling and passing to the microtask queue? 但是,对于诸如Promise之类的微任务,浏览器的Web Api是否也负责处理并传递给微任务队列?

If not, what is handling this process? 如果没有,该流程将如何处理?

The microtask queue is specified in the ES spec. 微任务队列在ES规范中指定。 The spec is implemented by JavaScript engines (most of them are browsers). 该规范由JavaScript引擎(大多数是浏览器)实现。

There is no such thing as "the Browser's Web Api", there are the Web Specs which defines setTimeout and such, browsers also implements that spec. 没有“浏览器的Web Api”之类的东西,有定义setTimeout 的Web规范 ,浏览器也实现该规范。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM