27 lines
556 B
Vala
27 lines
556 B
Vala
async void long_operation() {}
|
|
|
|
async void async_method(int idx, int max, MainLoopKeeper mlk) {
|
|
for(var i = 0; i < max; ++i) {
|
|
stdout.puts(@"async$idx:$i\n");
|
|
yield long_operation();
|
|
}
|
|
}
|
|
|
|
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, mlk);
|
|
async_method.begin(2, 3, mlk);
|
|
}
|
|
|
|
void main() {
|
|
var loop = new MainLoop();
|
|
start_methods(loop);
|
|
loop.run();
|
|
}
|