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 679896 - Simplify Util.run()
Simplify Util.run()
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: --
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-07-13 21:42 UTC by Zeeshan Ali
Modified: 2016-03-31 13:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
util: Add optional cancellable arg to run_in_thread (1.13 KB, patch)
2012-07-13 21:42 UTC, Zeeshan Ali
committed Details | Review
util: Simplify run() (1.51 KB, patch)
2012-07-13 21:42 UTC, Zeeshan Ali
committed Details | Review

Description Zeeshan Ali 2012-07-13 21:42:39 UTC
This function was mostly reimplementing run_in_thread() defined just above it so it wasn't very hard to reduce it to three lines.
Comment 1 Zeeshan Ali 2012-07-13 21:42:41 UTC
Created attachment 218760 [details] [review]
util: Add optional cancellable arg to run_in_thread
Comment 2 Zeeshan Ali 2012-07-13 21:42:43 UTC
Created attachment 218761 [details] [review]
util: Simplify run()

Basically it now just launches run_sync() through run_in_thread().
Comment 3 Christophe Fergeau 2012-07-14 20:05:27 UTC
Review of attachment 218761 [details] [review]:

I actually was wondering why we are not using g_spawn_async there instead of spawning stuff in a thread ourselves.

::: src/util.vala
@@ -464,2 @@
     public async void exec (string[] argv, Cancellable? cancellable) throws GLib.Error {
-        SourceFunc continuation = exec.callback;

No clue what exec.callback is? Is it something the caller can set?
Comment 4 Zeeshan Ali 2012-07-14 20:57:15 UTC
Review of attachment 218761 [details] [review]:

g_spawn_async doesn't exactly map to async style of GIO/Vala and hence is not so nice to use, especially if you want to (asynchornously) wait for the launched process to exit. That was the rationale *IIRC*.

::: src/util.vala
@@ -464,2 @@
     public async void exec (string[] argv, Cancellable? cancellable) throws GLib.Error {
-        SourceFunc continuation = exec.callback;

https://live.gnome.org/Vala/Tutorial#Asynchronous_Methods

No, it can't!
Comment 5 Zeeshan Ali 2012-07-14 21:49:53 UTC
Attachment 218760 [details] pushed as ef7e5ce - util: Add optional cancellable arg to run_in_thread
Attachment 218761 [details] pushed as ba8de1d - util: Simplify run()