Posts

Showing posts from April, 2017

NodeJS - Event Loop unveiled

Image
NodeJS : An asynchronous single threaded environment 😮 When started to work with nodeJS i was surprised that it was advertised as "asynchronous single threaded" environment.

So I've tried to understand how it worked and then, at the end, I have dealt with famous and notorious event loop. Moreover, during studying, I've also figured out that its operation was the same either when Javascript run in NodeJS than in the whatever Internet Browser.
The Event Loop In the image below has shown the basic event loop schema that make clear the architectural choices behind  the callback model (and as consequence the callback hell).
In fact such model allows to decouple the event loop thread, where the main application runs, from all the resource consuming operations.

Event Loop in NodeJS The image below adds more details to the previous one in particular, concerning event loop, we find out event queue and worker threads that give us a bit more info about its operation.



What the …