[Development] Views

Ulf Hermann ulf.hermann at qt.io
Tue Jun 11 11:03:32 CEST 2019


> I though about this as well. There's one caveat though. It can't be 
> (easily) made COW (if we require it). If your lookup is non-mutable 
> (i.e. `constFind` or w/e it's named), it'd mean that you have to mutate 
> the data in a const method. This implies doing it (thread-)safely is 
> going to get rather clumsy as there are 2 possibilities I see:
> 1) Detach in the `const` lookup if the data's dirty (i.e. not sorted) 
> and then sort it, and then do the lookup.
> 2) Lock the data block, sort it and then do the lookup.

3) Also sort the data on copying. Then you can still share the result. 
The "sorted" flag will always be set in the other thread and you can do 
an actually const lookup. If the sorted flag is not set on lookup you 
indeed need to detach (or do linear lookup).


More information about the Development mailing list