This is a question about JavaScript internals.
Lets say I have 10 async tasks that all take x number of seconds to run. Whilst waiting for a response the script is idle.
In the background the JavaScript engine is asking "Is there anything on the task queue". To my understanding this is a loop. Hence, event loop. I know in Node this is implemented with Libuv. I've read this article which explains a little: https://nikhilm.github.io/uvbook/basics.html
Do JavaScript engines place any restriction on how often this event loop runs in order to balance out performance of the application? Does it run at a set interval?
If I'm off with anything, please correct me. I was purely interested at what interval this event loop runs.
There is no loop per se in the JavaScript side. There is one in libuv though. Basically libuv will wait until the closest timer hits or an i/o operation happens. Then it will fire a callback in C, which calls the C++ function Node passed and then this triggers JavaScript code to be executed.
Have a look at this presentation, specially the section starting at slide 33.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With