Reputation: 808
I'm trying to understand the architecture of Event loop in Node.js. I came across side by side comparison between a server with setTimeout() and one with sleep() by while clause. setTimeout() was handled asynchronously but sleep() wasn't. http://www.atmarkit.co.jp/fcoding/articles/websocket/01/websocket01a.html (written in Japanese)
I understood this somewhat. But, I came up with a question, 'How can I find which blocks a process and which doesn't by reading source'. How do you determine it?
Upvotes: 0
Views: 251
Reputation: 25446
var result = calculateData(parameters)
than it block (btw every function in node block io processing loop, but most functions just queue io requests and exit)var start = new Date(); doesItBlock(function(err, result) { console.log('doesItBlock callback called after ' + (new Date - start)); }); console.log('doesItBlock exited after ' + (new Date - start));
Upvotes: 1