Common: Less strict memory ordering requirements for IObj

Applies the same relaxed restrictions as applied to boo in
4d91a1b3c3
and
84f62a0f2c
This commit is contained in:
Lioncash 2019-08-25 00:06:59 -04:00
parent c46bb3f72b
commit a8f4c1d34a
1 changed files with 5 additions and 3 deletions

View File

@ -150,11 +150,13 @@ protected:
virtual ~IObj() = default;
public:
void increment() noexcept { m_refCount++; }
void increment() noexcept { m_refCount.fetch_add(std::memory_order_relaxed); }
void decrement() noexcept {
if (m_refCount.fetch_sub(1) == 1)
if (m_refCount.fetch_sub(1, std::memory_order_release) == 1) {
std::atomic_thread_fence(std::memory_order_acquire);
delete this;
}
}
};
template <class SubCls>
@ -373,7 +375,7 @@ constexpr T clamp(T a, T val, T b) {
}
template <typename T>
constexpr T ClampFull(float in) {
constexpr T ClampFull(float in) noexcept {
if (std::is_floating_point<T>()) {
return in;
} else {