Relationship between event loop,libuv and v8 engine

后端 未结 3 1073
我寻月下人不归
我寻月下人不归 2021-02-01 19:45

I am learning through the architecture of Node.js. I have following questions.

  1. Is event loop a part of libuv or v8?
  2. Is event queue a part of event loop? a
3条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 20:36

    Go through these points:-

    1. V8 engine is the engine for coaches of train. It has certain responsibilites including providing event loop to run asynchronous task.

    2. Event loop is the core to perform async tasks. As soon as,C++ Web APIs finish a function(task) , callback is called.It is moved to event queue and waits untill stack becomes empty. Thus, event queue is part of event loop and are generated by event loop.

    3. V8 engine is used to execute the javascript code we write and libuv is a lbrary used to provide multi threading feature in Nodejs to execute long running processes.

    4. Event loop is single threaded but Nodejs is not single threaded as it has a libuv threadpool in its runtime which is responsible for multi threading.

    5. Browsers APIs also provide event loop.

提交回复
热议问题