[Development] QtCS2024 QFuture/QPromise

Morten Sørvig Morten.Sorvig at qt.io
Thu Sep 12 15:33:25 CEST 2024



> On 6 Sep 2024, at 22:36, Thiago Macieira <thiago.macieira at intel.com> wrote:
> 
> On Friday 6 September 2024 16:21:56 CEST Mårten Nordheim via Development 
> wrote:
>> But do we make it QList<int> _just in case_ there are multiple results
>> added?
> 
> From my limited exposure to QFuture/QPromise and in particular the bugs I've 
> had to triage, that is a design flaw.
> 
> The future/promise doesn't know how many results will be provided, so there's 
> a race condition in it flagging the future has arrived with more results 
> arriving.


QFuture is QGenerator in disguise.

Can we make it std::optional<T>? co_await awaits the next result, which might turn out to 
be "no result” (we don’t know at the time of the co_await call). Would that work?

Even in the case of a single result only that can still be “no result” in case of
cancellation, which again would suggest using an optional.

Morten




More information about the Development mailing list