rendered paste bodyGLib.MainLoop loop;
class Test : Object
{
public bool runitSync()
{
message( "before" );
intAsyncFunction();
message( "after" );
return false;
}
public async bool runitAsync()
{
message( "before" );
var n = yield intAsyncFunction();
message( "after: got %d", n );
return false;
}
public async int intAsyncFunction()
{
message( "intAsync state 1" );
Timeout.add_seconds( 5, intAsyncFunction.callback );
yield;
message( "intAsync state 2" );
return 42;
}
}
static int i = 0;
bool counter()
{
message( "%d", ++i );
if ( i == 10 )
loop.quit();
return true;
}
public int main( string[] argv )
{
message( "main()" );
loop = new GLib.MainLoop( GLib.MainContext.default(), false );
var t = new Test();
//Idle.add( t.runitAsync.begin );
Timeout.add_seconds( 1, counter );
//t.runitAsync();
Idle.add( t.runitAsync.begin );
message( "main() ==> loop" );
loop.run();
message( "main() <== loop" );
return 0;
}