Drop `SafeRefCount` in favor of C++11 atomics
Created by: RandomShaper
Primitive variables being treated as atomics are also promoted to std::atomic<T>
.
atomic_conditional_increment
and atomic_exchange_if_greater
still exist since they are useful, but are also meant to be used on C++11 atomics.
CowData
specifics:
- There's an
static_assert
near the top, ensuring that the memory layout of astd::atomic<uint32_t>
is just theuint32_t
itself, or that at least it doesn't require more memory than it. On the other hand, the standard guarantees that integer atomics are trivially copyable so it's OK to use raw memory functions on them (andreinterpret_cast
), just as if it were a plainuint32_t
. Anyway, when initializing the refcount it's made explicit that the intent is that they are atomic integers, even though the resulting machine code would be the same. - Removed misleading parameter from
_unref
.
Fixes #31860.
@akien-mga, I'm letting you set the milestone. Probably this is OK for 3.2 (I think none of the removed items were exposed to scripting of GDNative, but I'm not sure). Otherwise, or just for some safety, this should be for 4.0.