diff options
author | Evan Welsh <contact@evanwelsh.com> | 2022-05-07 00:01:52 -0700 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2023-02-20 21:15:34 -0800 |
commit | abcff91768b37aa2f437a5230046b61ffdab97b7 (patch) | |
tree | 2a4f9d7f9310c62bae4e052fd83a2a5335056d8c /gjs/mainloop.cpp | |
parent | 146787f52c896cba5737b8430f9fa03451e84e58 (diff) | |
download | gjs-abcff91768b37aa2f437a5230046b61ffdab97b7.tar.gz |
Introduce runAsync() to run main loops without blocking module resolution
All modules are promises. If Gtk.Application.run() or
GLib.MainLoop.run() is called within a module it will block all other
promises as run() is a synchronous, blocking function. To work around
this there is now a setMainLoopHook function exposed which runs a
callback after module resolution is complete. This allows APIs to
"install" a mainloop asynchronously.
For Gio.Application and GLib.MainLoop there are now runAsync() versions
of their run() functions. runAsync() returns a Promise which will
resolve once the mainloop has exited.
Fixes #468
Diffstat (limited to 'gjs/mainloop.cpp')
-rw-r--r-- | gjs/mainloop.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gjs/mainloop.cpp b/gjs/mainloop.cpp index 91109d61..b69d45a8 100644 --- a/gjs/mainloop.cpp +++ b/gjs/mainloop.cpp @@ -40,6 +40,8 @@ bool MainLoop::spin(GjsContextPrivate* gjs) { return false; } } while ( + // and there is not a pending main loop hook + !gjs->has_main_loop_hook() && // and there are pending sources or the job queue is not empty // continue spinning the event loop. (can_block() || !gjs->empty())); |