danvratil / qcoro

C++ Coroutines for Qt
https://qcoro.dvratil.cz
MIT License
326 stars 53 forks source link

Make not co_awaiting a coroutine trigger -Wunused-result #181

Open danvratil opened 1 year ago

danvratil commented 1 year ago

By annotating the right methods with [[nodiscard]] users should get -Wunused-result warning from compiler when they invoke a coroutine but don't store or co_await the returned Task.

ratijas commented 6 months ago

It seems to me that QCoro::Task is capable of completing itself, and even auto-magically handles destruction of its coroutine handle. I get it that in async context a Task likely should be awaited; but in a non-async function which is your entry point to call a coroutine, getting a Task object is not very useful, and would probably be discarded (while the actual coroutine runs to completion on its own). So, what would you suggest doing in the second situation? Storing a task in a dummy variable? casting it to void?