Questions tagged [event-loop]

Event loop refers to an infinite cycle of actions which is used for processing data based on callbacks and messages.

An event loop watches for I/O and timer state changes. It queues functions while waiting for unavailable resources, then dispatches them when resources are available.

References

1046 questions
-2
votes
1 answer

Comparison of Nodejs EventLoop (with cluster module) and Golang Scheduler

In nodejs the main critics are based on its single threaded event loop model. The biggest disadvantage of nodejs is that one can not perform CPU intensive tasks in the application. For demonstration purpose, lets take the example of a while loop…
CoderX
  • 942
  • 1
  • 10
  • 30
-2
votes
1 answer

Image won't render before setTimeout(0) call

Reference code: function sleep( sleepDuration ){ var now = new Date().getTime(); while(new Date().getTime() < now + sleepDuration){ /* do nothing */ } } function submit_answer(label) { let image = get_node('img.to_label') let size =…
chris
  • 1,831
  • 18
  • 33
-2
votes
1 answer

node js event loop and polling

In the case where I have an http request handler in node js which performs some heavy synchronous code, the event loop isn't free to poll for incoming requests. But these requests are not lost anywhere and they are stored in some buffer internally,…
Mister_L
  • 2,469
  • 6
  • 30
  • 64
-2
votes
1 answer

Is is bad practice to pass an empty callback in Javascript?

I have a long running function that I don't really care about handling properly. Is it bad practice to just hand it off to the event loop along with an empty callback and move on. Something like this: var takeSomeTime = function(callback) { var…
Pardoner
  • 1,011
  • 4
  • 16
  • 28
-2
votes
1 answer

node js performance for the individual user

A lot has been said about the high performance of node js, when compared to the multi-threaded model. But from the perspective of a single user, an http request is made, a db operation is issued, and the user will have to wait till the response from…
Mister_L
  • 2,469
  • 6
  • 30
  • 64
-2
votes
1 answer

Was the event loop model used in web browsers to control interaction between DOM events concomitantly developed by Brendan Eich with JavaScript?

Was the event loop evaluation model used in web browsers to control interaction between DOM events (and later the network) concomitantly developed by Brendan Eich with JavaScript? Or did it pre- or post-date JavaScript? Edit: I am specifically…
Ben Aston
  • 53,718
  • 65
  • 205
  • 331
-2
votes
1 answer

ANSI C compatible event loop

Is there an ANSI-C compatible event loop, like libev or libevent? My requirement is to compile with -ansi flag. Thank you.
Pio
  • 4,044
  • 11
  • 46
  • 81
-3
votes
2 answers

How does JavaScript call web APIs?

As far as I know, JavaScript's normal behavior when I call a web API just like the setTimeout 4 times: it should call the first one then add it to a queue waiting for the call stack to be empty .. repeatedly it will do the same for all other apis…
Ahmed Mansour
  • 500
  • 4
  • 14
-3
votes
3 answers

Why setTimeout function is non blocking?

If setTimeout is synchronous why its non blocking? On which thread does it execute if not main thread?
user5573523
  • 41
  • 2
  • 10
-3
votes
2 answers

Execution order in Promise()

Program - 1 new Promise(resolve => { resolve('1'); Promise.resolve().then(() => console.log('2')); }).then(data => { console.log(data); }); // output 2 1 Program -2 new Promise(resolve => { …
Rohit Goyal
  • 212
  • 1
  • 2
  • 8
1 2 3
69
70