summaryrefslogtreecommitdiff
path: root/tests/asynchronous/closures.vala
blob: 3212481a96bfc264e9e8bf506f5cbeb340cc97d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
delegate void Func ();

MainLoop main_loop;

async void foo (string baz) {
	unowned SourceFunc func = null;
	string bar = "hello";
	Func foobar = () => {
		func = null;
		bar = baz;
	};
	foobar ();
	assert (bar == "world");

	Idle.add (foo.callback);
	yield;

	main_loop.quit ();
}

void main () {
	foo.begin ("world");

        main_loop = new MainLoop (null, false);
        main_loop.run ();
}