简体   繁体   中英

In the case of node js the event queue or task queue is only meant for queuing tasks?

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 ?

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; 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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