Source: https://www.builder.io/blog/visual-guide-to-nodejs-event-loop
1. Timer Queue -> holds callback with setTimeout and setInterval functions
2. IO Queue -> holds methods asscoiated with Network and IO Operations
3. Check Queue -> Specific to NodeJs, for functions with setImmeditate
4. Close Queue -> Close event of an async task
The above queues are all part of libuv
5. Microtask Queue contains two other queues: a. Promise Queue b. NextTick Queue
github.com/persona-mp3
From the article, the flow of execution and prirotity of these queues is somewhat in this manner
- V8 Executes normal code
- When Stack is empty it checks the MicroTaskQueue
specifically the
nextTickand thenpromisequeue and feeds the callback functions to the V8 Stack - Then the
Timerqueue is checked, fed to the v8 stack and after, theMicroQueuesare checked again
And So on
1. main_stack -> micro_queue
executes [next_tick and promise_queue]
2. micro_queue -> timer_queue
3. timer_queue -> micro_queue
4. micro_queue -> io_queue
5. io_queue -> micro_queue
6. micro_queue -> check_queue
7. check_queue -> micro_queue
8. micro_queue -> close_queue
9. close_queue -> micro_queue