After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 663498 - Async methods must take in consideration the GMainContext
Async methods must take in consideration the GMainContext
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Async
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-11-06 12:34 UTC by Luca Bruno
Modified: 2018-05-22 14:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GAsync: Provide a convenient .idle_callback method for async methods (13.99 KB, patch)
2011-11-06 12:35 UTC, Luca Bruno
none Details | Review

Description Luca Bruno 2011-11-06 12:34:53 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.
Comment 1 Luca Bruno 2011-11-06 12:35:21 UTC
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.
Comment 2 Jürg Billeter 2012-08-01 10:31:51 UTC
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.
Comment 3 GNOME Infrastructure Team 2018-05-22 14:12:26 UTC
-- 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.