What's the Event Loop?
What's the Event Loop?
The Event Loop is a fundamental concept in Node.js that enables non-blocking I/O operations, allowing Node.js to perform asynchronous tasks such as reading from the filesystem, making network requests, and more. Despite JavaScript being single-threaded, the Event Loop facilitates concurrent operations by offloading operations to the system kernel whenever possible.
Phases of the Event Loop:
setTimeout() and setInterval().setImmediate().setImmediate() callbacks are invoked here.socket.on('close', ...).Each phase has a FIFO queue of callbacks to execute. The Event Loop enters a given phase, performs any operations specific to that phase, then executes callbacks in that phase's queue until the queue is exhausted or the maximum number of callbacks has executed.
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.