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
10
votes
1 answer

Triggering parallel of 1k HTTP requests would get stuck

The question is what is actually happening when you trigger 1k-2k outgoing HTTP requests? I see that it would resolve all the connections easily with 500 connections but moving up towards from there seems to cause problems as the connections are…
Risto Novik
  • 8,199
  • 9
  • 50
  • 66
10
votes
1 answer

What is event loop in ios life cycle and what is its usage and what it does?

I need to know what the event loop in the ios life cycle does?. Can any one suggest me regarding this??
Monish Kumar
  • 2,788
  • 4
  • 38
  • 54
10
votes
2 answers

Why setImmediate() execute before fs.readFile() in Nodejs Event Loop's works?

I have read a lot of related documents.But I still can't understand how it works. const fs = require('fs') const now = Date.now(); setTimeout(() => console.log('timer'), 10); fs.readFile(__filename, () => console.log('readfile')); setImmediate(()…
Zou Xin
  • 113
  • 1
  • 7
10
votes
3 answers

Python asyncio task ordering

I have a question about how the event loop in python's asyncio module manages outstanding tasks. Consider the following code: import asyncio @asyncio.coroutine def a(): for i in range(0, 3): print('a.' + str(i)) …
d512
  • 32,267
  • 28
  • 81
  • 107
10
votes
4 answers

Dart event queue and microtask

i am trying to understand, how dart event loop works. I read the event loop article from the website The Event Loop and Dart and the author explain pretty good how event loop in dart works. But what i don't understand is, how event get queue. For…
softshipper
  • 32,463
  • 51
  • 192
  • 400
10
votes
2 answers

Grab user input asynchronously and pass to an Event loop in python

I am building a single player MUD, which is basically a text-based combat game. It is not networked. I don't understand how to gather user commands and pass them into my event loop asynchronously. The player needs to be able to enter commands at any…
msystems
  • 101
  • 1
  • 1
  • 4
9
votes
2 answers

Raku equivalent to JavaScript's `setTimeout(fn, 0)`?

JavaScript's event loop uses a message queue to schedule work, and runs each message to completion before starting the next. As a result, a niche-but-surprisingly-common pattern in JavaScript code is to schedule a function to run after the messages…
codesections
  • 8,900
  • 16
  • 50
9
votes
4 answers

How does the libuv implementation of *non-blockingness* work exactly?

So I have just discovered that libuv is a fairly small library as far as C libraries go (compare to FFmpeg). I have spent the past 6 hours reading through the source code to get a feel for the event loop at a deeper level. But still not seeing where…
Lance
  • 75,200
  • 93
  • 289
  • 503
9
votes
1 answer

Remove work from a io_context or using multiple io_context objects

Currently I'm trying to make it possible to remove work queued through post or dispatch to an io_context. The work is queued by a small amount of queuer groups for which the work shall be removeable all at once: boost::asio::io_context…
Naios
  • 1,513
  • 1
  • 12
  • 26
9
votes
1 answer

Is it possible to create local event loops without calling QApplication::exec()?

I'd like to create a library built on top of QTcpServer and QTcpSocket for use in programs that don't have event loops in their main functions (because the Qt event loop is blocking and doesn't provide enough timing resolution for the real-time…
Nicolas Holthaus
  • 7,763
  • 4
  • 42
  • 97
9
votes
1 answer

Custom event loop and UIKit controls. What extra magic Apple's event loop does?

Does anyone know or have good links that explain what iPhone's event loop does under the hood? We are using a custom event loop in our OpenGL-based iPhone game framework. It calls our game rendering system, calls presentRenderbuffer and pumps events…
Teemu Kurppa
  • 4,779
  • 2
  • 32
  • 38
9
votes
2 answers

Event Loop in Qt-based DLL in a non-Qt application

I was searching the whole web for an answer but didn't find the solution for my problem. Or maybe I did but because I am a beginner to C++/programming/Qt I didn't understand them. The closest thing was a question here Using a Qt-based DLL in a…
emKaroly
  • 756
  • 1
  • 10
  • 22
9
votes
3 answers

Javascript internals - clearTimeout just before it fires

Let's say I do this: var timer = setTimeout(function() { console.log("will this happen?"); }, 5000); And then after just less than 5 seconds, another callback (from a network event in NodeJS for example) fires and clears…
Gus Hogg-Blake
  • 2,393
  • 2
  • 21
  • 31
9
votes
8 answers

Eclipse Unhandled event loop exception, no more handles Windows 7

My Eclipse is used to develop Android Apps. It worked fine until one day, an Unhandled event loop exception is prompt. The log is shown below. To trigger the error prompt, just unfocus the text editor in eclipse and focus it again, then the prompt…
user2873159
  • 91
  • 1
  • 1
  • 2
8
votes
1 answer

process.nextTick vs queueMicrotask in commonJs and ESM. What is the execution order?

Let's imagine we have a file containing next JS code: process.nextTick(()=>{ console.log('nextTick') }) queueMicrotask(()=>{ console.log('queueMicrotask') }) console.log('console.log') and we've set module system to "type": "commonjs" in…