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 604827 - Async Delegates
Async Delegates
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Async
unspecified
Other Linux
: Normal enhancement
: 2.0
Assigned To: Vala maintainers
Vala maintainers
patch
: 621542 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-12-17 12:36 UTC by Michael 'Mickey' Lauer
Modified: 2018-05-22 13:27 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Michael 'Mickey' Lauer 2009-12-17 12:36:18 UTC
Can we have 'em, please?
Comment 1 Jürg Billeter 2010-06-15 09:32:33 UTC
*** Bug 621542 has been marked as a duplicate of this bug. ***
Comment 2 Frederik Sdun 2010-09-07 21:42:25 UTC
Could you change the status to WIP?

my code is at: http://git.freesmartphone.org/?p=vala.git;a=shortlog;h=refs/heads/async

Async signal handlers for methods is already working
Comment 3 Luca Bruno 2011-01-09 17:45:08 UTC
Do we need to store another function (finish) when passing delegates around? Is it sufficient to pass the _async, _finish, target and destroy notify?
Comment 4 Frederik Sdun 2011-01-11 14:03:22 UTC
O don't pass the _async function. only _finish. 
If you want to use the .callback function you might need _co, too. But you can use the methods .callback and GLib.AsyncReadyCallback if you need it.
Comment 5 Luca Bruno 2011-01-11 20:09:17 UTC
(In reply to comment #4)
> O don't pass the _async function. only _finish. 
> If you want to use the .callback function you might need _co, too. But you can
> use the methods .callback and GLib.AsyncReadyCallback if you need it.

How are you supposed to call yourdeleg.begin () then?
Comment 6 Frederik Sdun 2011-01-11 21:11:48 UTC
that's the normal delegate
Comment 7 Jürg Billeter 2011-03-01 09:02:39 UTC
Is the async-new branch on fso ready for review or is this just part of what's needed?
Comment 8 Philip Withnall 2012-07-27 15:27:37 UTC
Any progress on this? We could really use it in folks.
Comment 9 Maciej (Matthew) Piechotka 2013-04-24 12:35:35 UTC
It would be nice way to make the spawning tasks in libgee nicer (in Future part of library).

For example if we want to call expensive_calculation and expensive_calculation2 in parallel and to their produce add the value of futures a and b.

Currently:

Future<double?> a, b;
Future<double?> c = task<double?>(() => {
    return expensive_calculation();
});
Promise<double?> promise = new Promise<double?>();
Future<double?> d = task<double?>(() => {
    double d_val =  expensive_calculation2();
    c.when_done((c_val) => {
        a.when_done((a_val) => {
            b.when_done((b_val) => {
                promise.set_value (c_val * d_val + a_val + b_val);
            });
        });
    });
});
return promise.future;

While with async delegates the following is possible:

Future<double?> a, b;
return task_async<double?>(() => {
    Future<double?> c = task<double?>(() => {
        return expensive_calculation();
    });
    double d_val = expensive_calculation2();
    double a_val = yield a.wait_async ();
    double b_val = yield a.wait_async ();
    double c_val = yield c.wait_async ();
    return c_val * d_val + a_val + b_val;
});
Comment 10 Guillaume Poirier-Morency 2016-04-08 22:32:56 UTC
I plan to work on that feature this summer. Any prior work? Frederick's link seems broken.
Comment 11 Michael 'Mickey' Lauer 2016-04-28 12:26:34 UTC
I have uploaded our Vala repository to https://github.com/freesmartphone/vala. The branch origin/playya/async contains e.g.

commit bfcbc0b26c94f8c61f91bd41dc23290536cc9dd9
Author: Frederik 'playya' Sdun <Frederik.Sdun@googlemail.com>
Date:   Fri Jan 28 15:43:34 2011 +0100

    Add support for async signal handlers

    Fixes bug 602594.

which might be interesting for you.

Note though that this work is over five years old... chances are many things have changed. For more questions, feel free to contact Frederik directly.
Comment 12 Maciej (Matthew) Piechotka 2016-05-04 15:57:23 UTC
If you want me to test it by introducing feature in libgee fell free to contact me about WIP. It would be cool if the libgee started using the feature when it gets introduced to Vala.
Comment 13 Guillaume Poirier-Morency 2016-05-05 05:33:34 UTC
(In reply to Maciej Piechotka from comment #12)
> If you want me to test it by introducing feature in libgee fell free to
> contact me about WIP. It would be cool if the libgee started using the
> feature when it gets introduced to Vala.

Sure, I will post update here for that purpose.

I'm on vacation until the 13 of June and then I'll look into it.

It might be worth the check the following post, it should give a good preview of the feature:

http://arteymix.github.io/2016/03/30/async-delegates.html

There's still an issue with how chaining would be done syntactically since anonymous function would not have access to 'name.callback'.

I like the idea to keep things in such a way that marking a delegate as asynchronous does not break API. Therefore no explicit 'async' keyword on the closure and more type inference ;)
Comment 14 Daniel Espinosa 2017-02-20 18:32:39 UTC
It seems to be a WIP with possible API break, then tagged for Vala 2.0 and enhancement.
Comment 15 GNOME Infrastructure Team 2018-05-22 13:27:25 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/66.