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 681136 - Allow ref our out parameters with async in scope
Allow ref our out parameters with async in scope
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2012-08-03 13:29 UTC by Marc-Andre Lureau
Modified: 2018-05-22 14:27 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Marc-Andre Lureau 2012-08-03 13:29:49 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
Comment 1 GNOME Infrastructure Team 2018-05-22 14:27:31 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/310.