diff options
| author | Fabian Kosmale <fabian.kosmale@qt.io> | 2025-10-16 11:23:33 +0200 |
|---|---|---|
| committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2025-10-27 17:35:04 +0000 |
| commit | e89d20181bcd38c25180ff7943cf48941710ead9 (patch) | |
| tree | 8418bcaba37e9ea2e3b42ec407d6b7ea2bdf0d32 /src/corelib/tools/qarraydata.h | |
| parent | 13f521e4983c7f3b4a77a4c521da1cfda992dad8 (diff) | |
QBasicAtomicInteger: Add (internal) refRelaxed
It is known that incrementing the refcount can use relaxed semantics,
compare
https://web.archive.org/web/20251016043603/https://devblogs.microsoft.com/oldnewthing/20251015-00/?p=111686
However, we can't modify QBasicAtomic::ref, because that is documented
to use "ordered" semantics.
So introduce a new (internal) refRelaxed method, which simply calls
fetchAndAddRelaxed(1) instead. Compared to ref, we also do not return
anything, as no expected user has a need for the return value (and it
only causes more work for the compiler to get rid of it again).
Our deref operation is still using acquire_release semantics, so
everything is fine.
Port QArrayData to use it as a first user so that the functionality is
tested.
Change-Id: I678870551fe85b83d9bb073ddb5947e649845264
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/tools/qarraydata.h')
| -rw-r--r-- | src/corelib/tools/qarraydata.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 5aadbeda538..aadf33ed5ae 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -58,7 +58,7 @@ struct QArrayData /// Returns true if sharing took place bool ref() noexcept { - ref_.ref(); + ref_.refRelaxed(); // suffices for ref-counting return true; } |
