
class Xyzzy : Object {
    private bool running = false;
    
    public Xyzzy() {
    }
    
    public async void query_async() throws Error {
        running = true;
        try {
            if (!yield internal_query_async())
                return;
        } finally {
            try {
                yield close_query_async();
            } catch (Error err) {
                // ignored
            }
            
            running = false;
        }
    }
    
    private async bool internal_query_async() throws Error {
        return true;
    }
    
    private async void close_query_async() throws Error {
    }
}

async void go_async() {
    Xyzzy x = new Xyzzy();
    try {
        yield x.query_async();
    } catch (Error err) {
    }
    
    loop.quit();
}

private MainLoop? loop = null;

void main(string[] args) {
    loop = new MainLoop();
    
    go_async.begin();
    
    loop.run();
}

