[Vala] calling delegate from async
- From: pHilipp Zabel <philipp zabel gmail com>
- To: vala-list <vala-list gnome org>
- Subject: [Vala] calling delegate from async
- Date: Fri, 23 Oct 2009 15:31:53 +0200
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]