event-loop

JavaScript Event Loop: Queue vs Message Queue vs Event Queue

ぐ巨炮叔叔 提交于 2019-12-04 12:03:49
问题 Reading through a lot of JavaScript Event Loop tutorials, I see different terms to identify the queue stores messages ready to be fetched by the Event Loop when the Call Stack is empty: Queue Message Queue Event Queue I can't find the canonical term to identify this. Even MDN seems to be confused on the Event Loop page as it calls it Queue first, then says Message Queue but in the tags I see Event Queue . Is this part of the Loop being defined somewhere in details, or it's simply an

Run NodeJS event loop / wait for child process to finish

本秂侑毒 提交于 2019-12-04 08:28:28
问题 I first tried a general description of the problem, then some more detail why the usual approaches don't work. If you would like to read these abstracted explanations go on. In the end I explain the greater problem and the specific application, so if you would rather read that, jump to "Actual application". I am using a node.js child-process to do some computationally intensive work. The parent process does it's work but at some point in the execution it reaches a point where it must have the

Possible to run multiple main loops?

痞子三分冷 提交于 2019-12-04 04:19:08
I'm working with both libfuse and the glib event interface and I've run into an issue where I need to run multiple main loops concurrently (glib's g_main_loop_run and fuse_loop_mt ). I've already attempted to created a detached thread for glib's event loop under a secondary context, e.g.: static void * event_loop(void *arg) { GMainLoop *event_loop; GMainContext *context; context = g_main_context_new(); g_main_context_push_thread_default(context); event_loop = g_main_loop_new(context, FALSE); g_main_loop_run(event_loop); return NULL; } ... pthread_t event_thread; pthread_attr_t thread_attr;

Does the JS callstack always have at least one frame?

扶醉桌前 提交于 2019-12-04 03:43:18
问题 I've recently seen a presentation on the JS event loop which is, frankly, brilliant, but I have a lingering question now about the JS call stack. If you think about the global execution context as, say, main(), is main() never resolved? My reasoning here is that, if it were, then the JS program would be complete, and no callbacks would happen. --edit My primary interest here is how the call stack is represented, in relation to the callback queue. If the event loop is said to wait until the

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

北城余情 提交于 2019-12-04 02:39:27
I need to know what the event loop in the ios life cycle does?. Can any one suggest me regarding this?? The best answer is probably the one provided by Apple in the "Main event loop" section of the Cocoa Application Competencies for iOS document. In the main event loop, an application continuously routes incoming events to objects for handling and, as a result of that handling, updates its appearance and state. An event loop is simply a run loop: an event-processing loop for scheduling work and coordinating the receipt of events from various input sources attached to the run loop. Every thread

Why can't I catch SIGINT when asyncio event loop is running?

半世苍凉 提交于 2019-12-04 02:10:39
Using Python 3.4.1 on Windows, I've found that while executing an asyncio event loop , my program can't be interrupted (i.e. by pressing Ctrl+C in the terminal). More to the point, the SIGINT signal is ignored. Conversely, I've determined that SIGINT is handled when not in an event loop. Why is it that SIGINT is ignored when executing an asyncio event loop? The below program should demonstrate the problem - run it in the terminal and try to stop it by pressing Ctrl+C, it should keep running: import asyncio import signal # Never gets called after entering event loop def handler(*args): print(

Does calling QDialog::exec in a slot block the main event loop?

泄露秘密 提交于 2019-12-03 15:34:28
My Qt application's main window is a normal QMainWindow subclass. In that window I have a few buttons; each has its clicked signal connected its own slot, and each slot creates a different QDialog like so: void onButtonA_clicked() { MyADialog* dialog = new MyADialog(this); dialog->exec(); delete dialog; } I've been reading this article: https://wiki.qt.io/Threads_Events_QObjects#Events_and_the_event_loop and the author says you should never ever block the event loop which got me concerned; exec is a blocking function, so according to what he says there (his example with Worker::doWork which

Basic Event Loop in Python [duplicate]

寵の児 提交于 2019-12-03 15:11:21
This question already has answers here : Possible Duplicate: Event loop implementation for Python 3? I am trying to implement an event loop in python2.7. I would like to be able to trigger events based on a time event and as a result of another action taking place. I understand I can make use of select to do something similar to this. Is this the right way forwards or is there a better way which I am missing? An event loop is a loop which handles / deals with events. An event is something that occurs in the system where some code parts might be interested in. At the beginning, all components

What is the different between JavaScript Event loop and Node.js Event loop?

时光毁灭记忆、已成空白 提交于 2019-12-03 09:32:27
In JavaScript, the event loop is used in the engine. Here is one diagram to illustrate it from this article . (source: mybalsamiq.com ) For Node.js, the event loop also implemented here. Quoting from this question . The Node.js event loop runs under a single thread, this means the application code you write is evaluated on a single thread. Nodejs itself uses many threads underneath trough libuv, but you never have to deal with with those when writing nodejs code. However, it is still abstract for me about node.js event loop. Is there any image to introduce it more clearly? What's the different

JavaScript - When exactly does the call stack become “empty”?

时光毁灭记忆、已成空白 提交于 2019-12-03 08:51:07
问题 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 become "empty"? For example, <script> function f() { console.log("foo"); setTimeout(g, 0); console.log("foo again"); } function g() { console.log("bar"); } function b() { console.log("bye"); } f(); /*<---- Is the stack empty here? */ b(); </script> The