Job Queues and JavaScript Runtime

Node.js provides process.nextTick, which ensures that the called callback is invoked when control returns at runtime. This puts you at risk of starving an event loop, preventing the evaluation of jobs in the job queue.

Internet Explorer provides setImmediate, which, as far as I can tell, uses a separate task queue and some logic so that elements exit the queue once per iteration of the loop, excluding the "event loop puzzle".

requestAnimationFrame supports its own callback queue, which will be called one after another immediately before the VBLANK graphics subsystem.

Is it right to say that the JavaScript runtime coordinates the execution of tasks from different queues, putting them in an event loop for execution, from time to time determined by algorithms specific to these queues, and that in a sense, what happens is more that one event loop is serviced one job queue?

+4
source share
1 answer

How the queue works, and if there is more than one, depends on the implementation, but it is possible to have more than one queue and special rules that determine which task the queue will be executed from first.

+1
source

All Articles