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
25
votes
3 answers

Qt event loop and unit testing?

I'we started experimenting with unit testing in Qt and would like to hear comments on a scenario that involves unit testing signals and slots. Here is an example: The code i would like to test is (m_socket is a pointer to QTcpSocket): void…
TheMeaningfulEngineer
  • 15,679
  • 27
  • 85
  • 143
24
votes
1 answer

How are the Event Loop, Callback Queue, and Javascript’s single thread connected?

GENERAL GOAL I’d like to know how the following pieces of a javascript environment interconnect as a system. Javascript Engine Event Loop Event Queue We can limit this to a browser environment since node has been covered in another article…
23
votes
4 answers

How to detect and measure event loop blocking in node.js?

I'd like to monitor how long each run of the event loop in node.js takes. However I'm uncertain about the best way to measure this. The best way I could come up with looks like this: var interval = 500; var interval = setInterval(function() { …
Fabian Jakobs
  • 28,815
  • 8
  • 42
  • 39
22
votes
4 answers

What's the cleanest way to write a non-blocking for loop in javascript?

So, I've been thinking about a brain teaser - what if I had a large object I for some reason had to iterate through in node js, and didn't want to block the event loop while I was doing that? Here's an off-the-top-of-my-head example, I'm sure it can…
Jesse
  • 10,370
  • 10
  • 62
  • 81
21
votes
1 answer

What is a browser event loop?

I have been doing some web application programming using GWT and have been confused by the term "browser event loop". I have encountered situations where I need to execute deferred commands and "do something" after the browser event loop…
gofeddy
  • 579
  • 8
  • 20
19
votes
3 answers

Qt: Is there notification when event loop starts?

I have a Qt application with this kind of main()... int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow mainWin; ... A separate, non-GUI thread is launched here mainWin.Init(); mainWin.show(); …
BabaBooey
  • 1,552
  • 3
  • 21
  • 38
19
votes
1 answer

Does V8 have an event loop?

I keep hearing V8 has its rudimentary event loop implementation but couldn't find it doesn't really make sense to me. Methinks, the simplest design of a JS engine would be to simply run synchronously and let the "embedder" write their own event…
Novellizator
  • 13,633
  • 9
  • 43
  • 65
19
votes
1 answer

Eventloop has high ksoftirqd load; nginx does not but does same system-calls. Why?

I wrote some code that has an epoll-eventloop, accepts new connections and pretends to be a http-server. The posted code is the absolute minimum ... I removed everything (including all error-checks) to make it as short and to the point as…
Xatian
  • 772
  • 1
  • 8
  • 24
19
votes
4 answers

JavaScript - When exactly does the call stack become "empty"?

I've read several posts/SO threads on event loop, and according to MDN's article, When the stack is empty, a message is taken out of the queue and processed. As a JS novice, what I'm still confused about is -- when exactly does the call stack…
Yibo Yang
  • 2,353
  • 4
  • 27
  • 40
18
votes
2 answers

When to use multiple event loops?

I have a web app built on a Python 3.5+ async framework (apistar, sanic, etc). The app makes various IO calls - to a database, Redis, etc - which are also async. Some docs recommend using an additional event loop: import asyncio import peewee from…
knite
  • 6,033
  • 6
  • 38
  • 54
18
votes
2 answers

node.js Event Loop Diagnostics

Is it possible to peek at the event loop for diagnostics? I would like to know how many events are currently waiting for execution (excluding setTimeout/interval). Update: I'd like to do this from inside the running node process.
laktak
  • 57,064
  • 17
  • 134
  • 164
17
votes
3 answers

What is the difference between the event loop in JavaScript and async non-blocking I/O in Node.js?

In this answer to the question - What is non-blocking or asynchronous I/O in Node.js? the description sounds no different from the event loop in vanilla js. Is there a difference between the two? If not, is the Event loop simply re-branded as…
Flame of udun
  • 2,136
  • 7
  • 35
  • 79
17
votes
2 answers

Monitoring the size of the Netty event loop queues

We've implemented monitoring for the Netty event loop queues in order to understand issues with some of our Netty modules. The monitor uses the io.netty.util.concurrent.SingleThreadEventExecutor#pendingTasks method, which works for most modules, but…
Eran Harel
  • 2,325
  • 19
  • 28
16
votes
1 answer

Working of call stack when async/await is used

How does the Call Stack behave when async/await functions are used ? function resolveAfter2Seconds() { // taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function return new Promise(resolve => { …
16
votes
2 answers

What is the overhead of an asyncio task?

What is the overhead of any asyncio task in terms of memory and speed? Is it ever worth minimising the number of tasks in cases when they don’t need to run concurrently?
Michal Charemza
  • 25,940
  • 14
  • 98
  • 165
1
2
3
69 70