What is difference between callbacks in pending_queue and poll_queue of event loop in Node.js

440 Views Asked by At

enter image description here

As we can see in above Libuv code for event loop, first callbacks in pending_queue runs. After that I/O Polling happens. So what is the difference between I/O callbacks in pending_queue and poll_queue?

1

There are 1 best solutions below

0
Ahmed Alashi On

poll callbacks are those who have finished their execution and waiting for the event loop to pick them up and pass them to the event/message queue and then to the call stack on a FIFO basis.

They are the callbacks that are ready to be executed. >> THEY ARE Done/Ready/Finished/Processed >> they are waiting for the event loop to pick them up to pass them to the message queue and then to the call stack.

pending callbacks are those that are still waiting/pending/in-thread/processing callbacks and waiting for the appropriate tick to handle them when they are actually finished.

They are the callbacks that are deferred/postponed to the next loop iteration. >> they are still/waiting/processing/in-thread.