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

why yield in event loop?

anI used a C++ framework, where yield at the end of every loop cycle was mandatory. Now that I'm starting with C# and C++/CLI, I came across the yield function as well. I'm creating an event loop and was wondering if the use of yield is necessary.…
JMRC
  • 1,473
  • 1
  • 17
  • 36
0
votes
1 answer

Access .net form main loop, or an event which is triggered every frame

I made an app with an API that allowed me to create my own event loop. I’m trying to get that same effect with the .NET forms to convert this application. It basically looked like this: int main() { InitializeComponents(); …
JMRC
  • 1,473
  • 1
  • 17
  • 36
0
votes
1 answer

Java event loop, sleep "gently"

I'm doing a sort of event loop to process multiple non-blocking sockets in Java. The problem is that when I leave the loop untouched, it uses a whole core. (For instance, I have a quad core and everytime I start my program, the CPU jumps to 25%…
SBSTP
  • 3,479
  • 6
  • 30
  • 41
0
votes
2 answers

Trouble with keeping Node.js asynchronous

So, I ran into a situation today in which I needed to place an asynchronous database call into a custom function of mine. For example: function customfunction(){ //asynchronous DB call } Which I then call from another point in my program. First…
Ari
  • 3,489
  • 5
  • 26
  • 47
0
votes
1 answer

set a deadline for each callback in an event-driven/ event-loop based program

In a typical ASIO or event-based programming library like libevent, is there a way to set a deadline for each callback? I am worried about possible infinite loops within the callbacks. Is there a way to gracefully detect them, remove the misbehaving…
Swaroop
  • 91
  • 4
0
votes
1 answer

TideSDK and long processing loops in Python

Is there a way to do long processing loops in Python without freezing the GUI with TideSDK? or I'll just have to use threads... Thanks.
leferreyra
  • 189
  • 2
  • 8
0
votes
2 answers

GTK main blocks -- Python

I am new to GTK and I stumbled upon a problem which sounds simple but I just can't find a way to deal with it. Basically, calling gtk.main() makes my single-threaded process halt. I know that gtk.main() is blocking, but I have not called gtk.main()…
zpavlinovic
  • 1,507
  • 1
  • 17
  • 36
0
votes
2 answers

Understanding the Objective-C event loop

How can I log every message sent in a single iteration of the Objective-C event loop? I want to further my understanding of the Objective-C runtime and thought this would be a good start.
SundayMonday
  • 19,147
  • 29
  • 100
  • 154
0
votes
1 answer

Does the js event-loop mean you can use global variables for temp scratch-space?

* Disclaimer: I'm not saying this is a good idea - as a matter of fact I'll explicitly say it is not - so take this question by way of trying to understand what exactly the event-loop means for coding style. My rudimentary understanding of the…
George Mauer
  • 117,483
  • 131
  • 382
  • 612
0
votes
1 answer

Gtkmm: Adding Window at later time

Because I´m writting a "generic" application behaving completely different when facing other configurations, I´m forced to show gtk windows even if I dont yet know them at startup. There might also be the requirement that multiple windows need to be…
Sebastian Hoffmann
  • 11,127
  • 7
  • 49
  • 77
0
votes
2 answers

Modal Loop in a GTK+ application

I am trying to write a function which will wait till the user clicks somewhere within a GTK+ widget (similar to a drawing area) and return mouse co-ordinates. This function should behave modally in that it waits till input is received. Those…
Agnel Kurian
  • 57,975
  • 43
  • 146
  • 217
-1
votes
2 answers

I am using setTimeout and fetch API both, bot didn't understand which one will execute first?

fetch('https://jsonplaceholder.typicode.com/todos/1') .then(response => response.json()) .then(json => console.log(json)) setTimeout(()=>{ console.log("Callback after delay") },1000) setTimeout(()=>{ console.log("Callback with no…
-1
votes
1 answer

What is the difference between asynchrony in c# and in javascript

In python and js, there is often a problem associated with blocking the event loop, when the code is executed in one thread and only one synchronous operation can be performed at the same time, but I could not find this problem anywhere in C#, maybe…
RomanGodMode
  • 325
  • 3
  • 11
-1
votes
2 answers

Why doesn't event loop have timeout for microtasks?

async function() { while (true) { await null; } } This will block the thread forever, because the event loop would try to finish all microtasks in one frame. (async () => { for (let i = 0; i < 999999; i++) { await null; …
-1
votes
2 answers

Why does Promise hold the execution of the Call Stack?

function main() { console.log("S-1"); setTimeout(() => { console.log("setTimeout"); }, 0); new Promise((resolve, reject) => { for (let i = 0; i < 10000000000; i++) {} resolve("Promise"); }).then((res) => console.log(res)); …