0

In the case of nodeJs the event queue or task queue is only meant for queuing tasks and if any kind of asynchronous call is there , is that handled by c++ api's present within libuv library .

for example if any db query is happening , how exactly the process flows ?

Piyush Biswal
  • 137
  • 1
  • 8

1 Answers1

0

The lib you are using in Node.JS makes the request to the database, and frees the queue. While the database does not respond to you, other processes can arrive and be processed perfectly. And so when the database responds to you, it will come as a callback for you. That's at least if you've been using Node.JS the correct way, which is abusing callbacks.

This is known as Event Loop; enter image description here

  • What exactly is this intensive operation and i guess event loop is not the single thread which iam talking about – Piyush Biswal Mar 14 '18 at 07:28
  • These are external things that are no longer part of the Node. Example: When you pass a task to the database, the responsibility is not of the node anymore. It keeps waiting for the database to give you an answer. In the middle, the node will do other tasks, while the database processes. This is not blocking, unlike other languages like PHP that would wait for the database response before doing something else. – Daniel Bastos Mar 15 '18 at 07:50