Hasty Briefsbeta

Bilingual

QFuture Loves C++ Coroutines

3 months ago
  • #Qt
  • #Coroutines
  • #C++
  • C++20 introduced coroutine support, leading to the development of QCoro, a library for integrating coroutines with Qt.
  • The author created QAwaitableFuture, a lightweight wrapper that makes QFuture and QPromise compatible with coroutines, simplifying async operations.
  • QAwaitableFuture allows for syntax sugar around QFuture::then(), supports cancellation propagation, and exception handling.
  • Features include continueOn() for configuring coroutine resumption, similar to QFuture::then(), and direct access to QPromise for progress reporting and cancellation checks.
  • The author aims to upstream QAwaitableFuture into Qt, possibly in version 6.12, and provides a single-header solution for immediate use.
  • A caveat exists for GCC versions before 13.0.0 due to a bug affecting coroutine support with temporary lambdas, requiring workarounds.