[Development] atomic reference counting implementation

Konstantin Tokarev annulen at yandex.ru
Wed Aug 7 21:01:08 CEST 2019



07.08.2019, 21:02, "Mutz, Marc via Development" <development at qt-project.org>:
> Hi Philippe,
>
> This was discussed in
> https://codereview.qt-project.org/c/qt/qtbase/+/66118. See, in
> particular, Olivier's comment.
>
> TL;DR: ref() is documented to be ordered, so cannot be changed.
>
> Consequently, I didn't merge it even with Thiago's +2.
>
> To fix, we'd need to port all of the Qt classes away from the public
> classes (QSharedData, QAtomicInt) and implement ref-counting completely
> from scratch (well, copy QSharedData → QSharedDataV2, QAtomicInt →
> QAtomicIntV2, and do the change in V2). That, or we introduce silent
> breakages into user code by applying 66118, something our Chief Whip has
> just announced publicly should not happen:
>
> https://blog.qt.io/blog/2019/08/07/technical-vision-qt-6/
>>  If we must break compatibility, a compile-time error is preferable
>>  over a silent breakage at runtime (as those are much harder to detect).
>
> I think I'm on record saying such impl details as ref-counting for Qt
> implicitly shared classes should not be public API. This is a perfect
> example of why I believe that to be fundamentally true.

It would be even better if it was possible to choose type of reference counting,
e.g. via template parameter. In many cases atomic counters are not needed
and just reduce performance.

-- 
Regards,
Konstantin




More information about the Development mailing list