浏览代码

Use the right memory ordering in SafeNumeric operations

(cherry picked from commit 02a584d8e68fad988fbbe43e05f8437284c00733)
Pedro J. Estébanez 3 年之前
父节点
当前提交
4e1f30390d
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      core/safe_refcount.h

+ 2 - 2
core/safe_refcount.h

@@ -113,7 +113,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;
 			}
 			}
 		}
 		}
@@ -125,7 +125,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;
 			}
 			}
 		}
 		}