Hi,

I'd like to call a delegate function from an async function, like this:

class AsyncDelegate {
        delegate void TestFunc ();

        void test_func () {
                print ("delegate\n");
        }

        async void test_async (TestFunc f) {
                print ("async enter\n");
                Idle.add (test_async.callback);
                yield;
                f ();
                print ("async leave\n");
        }

        static int main (string[] args) {
                var loop = new GLib.MainLoop (null, false);
                var app = new AsyncDelegate ();

                app.test_async.begin (app.test_func);
                print ("loop\n");
                loop.run ();

                return 0;
        }
}

But Vala 0.7.7 doesn't like that at all:

** (valac:7627): CRITICAL **: vala_data_type_get_value_owned:
assertion `self != NULL' failed
/home/ph5/vala/async-delegate/async-delegate.vala.c:44: error:
expected specifier-qualifier-list before Б─≤AsyncDelegateTestFuncБ─≥
[...]
Compilation failed: 1 error(s), 0 warning(s)

When I turn test_async into a sync function again, it works just fine.
Trying to turn TestFunc into an async delegate function (and call it
with yield f ()) on the other hand, seems to be even more critical:

** (valac:7707): CRITICAL **: vala_data_type_get_value_owned:
assertion `self != NULL' failed
** (valac:7707): CRITICAL **:
vala_ccode_expression_statement_construct: assertion `expr != NULL'
failed
** (valac:7707): CRITICAL **: vala_ccode_fragment_append: assertion
`node != NULL' failed
/home/ph5/vala/async-delegate/async-delegate.vala.c:52: error:
expected specifier-qualifier-list before Б─≤AsyncDelegateTestFuncБ─≥
[...]
Compilation failed: 1 error(s), 0 warning(s)

regards
Philipp
_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to