3 ms·
An event loop is basically a single thread that executes functions from a FIFO queue. A function can put itself on a queue by "yielding", which means, allowing
by phoe-krk 7y ago
An event loop is basically a single thread that executes functions from a FIFO queue. A function can put itself on a queue by "yielding", which means, allowing other functions to execute.
If your function blocks, for example, by performing a wait on something without yielding, then nothing else gets computed because of the wait, but the event queue is occupied since the function has not yielded. This breaks the cooperative part of the cooperative multithreading mechanism of Node.
- MayeulC 7y agoAll right, thank you. So it's basically the same as any other non-preemptive multitasking design. If the event loop is part of the Node language/runtime, I can see the case for making it preemptive.
- Izkata 7y ago> So it's basically the same as any other non-preemptive multitasking design. All this has happened before. All this will happen again.