GNOME Bugzilla – Bug 681136
Allow ref our out parameters with async in scope
Last modified: 2018-05-22 14:27:31 UTC
It is currently not possible to use: yield exec (argv, null, out standard_output); public delegate void RunInThreadFunc () throws GLib.Error; public async void run_in_thread (RunInThreadFunc func, Cancellable? cancellable = null) throws GLib.Error { GLib.Error e = null; GLib.g_io_scheduler_push_job ((job, cancellable) => { try { func (); } catch (GLib.Error err) { e = err; } job.send_to_mainloop (() => { run_in_thread.callback (); return false; }); return false; }, GLib.Priority.DEFAULT, cancellable); yield; if (e != null) throw e; } public async void exec (string[] argv, Cancellable? cancellable, out string? standard_output = null, out string? standard_error = null) throws GLib.Error { yield run_in_thread (() => { exec_sync (argv, standard_output, out standard_error); }, cancellable); } I use the following workaround: public async void exec (string[] argv, Cancellable? cancellable, out string? standard_output = null, out string? standard_error = null) throws GLib.Error { string std_output = ""; string std_error = ""; yield run_in_thread (() => { exec_sync (argv, out std_output, out std_error); }, cancellable); standard_output = std_output; standard_error = std_error; } 09:20 < juergbi> elmarco: we should be able to add support for this 09:20 < juergbi> the check against ref/out was probably added before we had async methods 09:21 < juergbi> assuming vala knows that run_in_thread argument will run in-scope
-- 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/310.