Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Event loop in Node.js

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 181
    Comment on it

    In all the event driven programming, there is a main loop that listen's the events, and then invoke the corresponding callback function whenever one of those events occur.


    Here we might get confuse between events and callback, But the difference is that a callback gets executed when an asynchronous function is completed whereas events follow the observer pattern. In observer pattern whenever an event triggers its listener gets executed.
    As we know node is single threaded so the event loop in node.js allows node server to handle requests concurrently.
    There is an event queue which consists of all the events and their corresponding callback function. And there are threads in thread pool which handles all the I/O asynchronously.


    Event loop start iteration from the event queue, and if there is any I/O (asynchronous) operation, it will handle it to the thread pool.Event loop continues execution of events in the event queue. And when the I/O operation is complete, its corresponding callback is pushed in the event loop for processing and provide appropriate results

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: