async def download(url): ...await download(url)
C++ (Qt)void Test( void ){ InitData(); SomeCoRoutine() AnalyzeResults();}
int main(int argc, char *argv[]){ QApplication app(argc, argv); // a really simple widget ColorRect cr; cr.setWindowTitle("Color Cycler"); cr.show(); qDebug() << "before coro"; // change widget color every 500ms QTimer * changeTimer = new QTimer(&app); auto ro = [&]() -> qtcoro::return_object<> { qDebug() << "entering coro"; while (true) { qDebug() << "entering loop"; co_await qtcoro::make_awaitable_signal(changeTimer, &QTimer::timeout); qDebug() << "awaited"; cr.changeColor(); } }(); qDebug() << "after coro"; changeTimer->start(5000); qDebug() << "entering exec()"; return app.exec();}
before coroentering coroentering loopafter coroentering exec()awaitedentering loopawaitedentering loop
def foo(): ...a = foo()b = bar(a)c = baz(b)
async def foo(): ...a = await foo()b = await bar(a)c = await baz(b)