GNOME Bugzilla – Bug 663498
Async methods must take in consideration the GMainContext
Last modified: 2018-05-22 14:12:26 UTC
Hello, currently async methods provide a .callback so that people can use Idle.add (foo.callback). But it's generally not correct to resume the async method in the default main context. For example gdbusconnection.c in gio stores the the GMainContext the async operation was created in, and creates idles and timeouts in that context. Proposal: 1) Store the main context when in the async data structure 2) Add a convenient .idle_callback method that automatically creates an idle source and attaches it to the right context. Most of the time Idle.add() is used to resume the async method. 3) Add a .main_context field to access the main context to allow other kind of sources to be attached.
Created attachment 200827 [details] [review] GAsync: Provide a convenient .idle_callback method for async methods The idle_callback will attach an idle function for .callback in the context the async operation was created in.
Are there really many cases where an idle source is useful in this context? Proper async operations typically build on top of other async functions or threads. Also, I think it would be better to provide something like an async idle() function than to require the use of yield statements as it's easy to use yield statements incorrectly.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/244.