Answer the question
In order to leave comments, you need to log in
What does data processing do in an asynchronous model?
Let's analyze it in more detail: we have an asynchronous reading from a file, when the read function is called, control is immediately transferred further, Node.js processes other requests. As soon as the file is read, the anonymous function passed to readFile as the second parameter is called. More precisely, the event associated with it is queued and when the queue reaches it, it is executed. Thus, we do not violate the sequence of actions: first the file is read, then it is processed. But at the same time, we do not take CPU time by waiting, but allow us to process other events in the queue.
Answer the question
In order to leave comments, you need to log in
According to the documentation , to perform asynchronous operations related to the file system, the node launches several parallel threads.
The most important thing to know is that the operating system interface is called, the Node itself does not read the file. Next is the operating system. As soon as a response is received on this call, the corresponding event will occur and the callback will be called.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question