Event-driven and non-blocking mode

Node.js is a JavaScript runtime environment Chrome V8 engine. 
Node.js uses an event-driven, non-blocking I / O model, making it lightweight and efficient.

The foregoing is the introduction node.js, node.js based typescript writing, typesript is a superset of javascript, so node.js is a single-threaded application, then we introduce -> What is event-driven.

ps: typescript is a superset of Microsoft's development of open source javascript framework, but it is not very strict use javascript, are interested can understand the next Baidu,

Event-driven, my personal understanding is that when he needed to perform, when not needed is not executed.

When he needed it, when you click on your keyboard, this time listening mechanism could monitor what did you do, if you do not click, he has been listening, but will waste memory, affect the speed of the computer, and when you use time drive, such as node.js will create a loop, the loop will view the events in the queue if there is to be performed, there is need to be performed again to perform the relevant function, can effectively save computer memory,

Behind nonblocking I / O;

Then we introduce what is non-blocking I / O it,

Asynchronous to execute each event, when you click a button, node.js event will be performed by placing a waiting thread pool, if encounter a lot of buttons to call together, then we need to get in the end asynchronous time to do the same anything.

 

 

The figure is understood, it is an asynchronous method invocation node.js to other operations, and finally through the callback function to return the content execution,

Baidu to find some documents, node.js use of single-threaded, away from the deadlock, state synchronization problem, use asynchronous I / O, so that single-threaded away from the obstruction, which will make better use of system memory,

That is more than some of my basic understanding of the node.js;

Guess you like

Origin www.cnblogs.com/Tmode/p/10941990.html