Merge pull request #63187 from RandomShaper/fix_atomic_cmp_exchange

This commit is contained in:
Rémi Verschelde 2022-07-19 17:09:59 +02:00 committed by GitHub
commit cce330bda5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,7 +111,7 @@ public:
if (tmp >= p_value) { if (tmp >= p_value) {
return tmp; // already greater, or equal return tmp; // already greater, or equal
} }
if (value.compare_exchange_weak(tmp, p_value, std::memory_order_release)) { if (value.compare_exchange_weak(tmp, p_value, std::memory_order_acq_rel)) {
return p_value; return p_value;
} }
} }
@ -123,7 +123,7 @@ public:
if (c == 0) { if (c == 0) {
return 0; return 0;
} }
if (value.compare_exchange_weak(c, c + 1, std::memory_order_release)) { if (value.compare_exchange_weak(c, c + 1, std::memory_order_acq_rel)) {
return c + 1; return c + 1;
} }
} }