4 ms·
> It may be better to ask yourself what does await do? Yes, probably that's something that slips me too. > It is easy to understand for us what come back mean
by endorphine 5y ago
> It may be better to ask yourself what does await do?
Yes, probably that's something that slips me too.
> It is easy to understand for us what come back means, but how to express that in an language? First attempt was with callbacks - node would come back to whatever you put in the callback.
I feel like I have to even understand what NodeJS does when you give it a callback function. So, how the asynchronous model works in a pre-Promise, pre-async/await world? And then when the loop is notified from epoll that a response came back, it goes and executes that callback function with the data?
Is that why they say that in async, the state is spilled all over the heap? Because the original function that issued the HTTP request and provided the callback, returned immediattely, and that callback function had to be allocated somewhere on the heap so that it could be executed eventually when that I/O was complete?
Does NodeJS uses epoll to ask to be notified when a response from a TCP socket comes in, and then puts the callback function in some kind of internal queue (the one that the event loop consumes from?)?