Use the right memory ordering in SafeNumeric operations

(cherry picked from commit 02a584d8e68fad988fbbe43e05f8437284c00733)
This commit is contained in:
Pedro J. Estébanez 2022-07-19 10:04:59 +02:00 committed by Relintai
parent f8be7dd320
commit a58186c82a

View File

@ -112,7 +112,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;
} }
} }
@ -124,7 +124,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;
} }
} }