29 lines
666 B
Vala
29 lines
666 B
Vala
async void do_smth () {}
|
|
async void async_method(int idx, int max, int step, MainLoopKeeper mlk) {
|
|
for(var i = 0; i < max; ++i) {
|
|
stdout.puts(@"Async$idx:$i\n");
|
|
for(var j = 0; j < step; ++j) yield do_smth();
|
|
}
|
|
}
|
|
|
|
public class MainLoopKeeper {
|
|
MainLoop _loop;
|
|
public MainLoopKeeper(MainLoop loop) { _loop = loop; }
|
|
~MainLoopKeeper() { _loop.quit(); }
|
|
}
|
|
|
|
void start_methods(MainLoop loop) {
|
|
var mlk = new MainLoopKeeper(loop);
|
|
async_method.begin(1, 8, 1, mlk);
|
|
async_method.begin(2, 3, 2, mlk);
|
|
}
|
|
|
|
void main() {
|
|
var loop = new MainLoop();
|
|
stdout.puts("main:1\n");
|
|
start_methods(loop);
|
|
stdout.puts("main:2\n");
|
|
loop.run();
|
|
stdout.puts("main:3\n");
|
|
}
|