4 ms·
> can be converted to: Not necessarily! In a typical eventloop system - like with libuv - events and readiness will be checked within the eventloop while no us
by Matthias247 5y ago
> can be converted to:
Not necessarily! In a typical eventloop system - like with libuv - events and readiness will be checked within the eventloop while no user code is executed. The eventloop runs something along:
while (true) {
waitForOsEventsOrTimers(); // Uses epoll & co
executeAllReadyCallbacks();
}
Your whole promise code is part of `executeAllReadyCallbacks`. Thereby any blocking there will block fetching new readiness events, and thereby the code will be stuck.
It would only work if the polling OS functions would run on a different thread - which some runtimes like .NET might actually do. However its very often avoided since its less efficient than polling events inline without synchronization, and in Javascript wouldn't work.
When you now use the c