Skip to content

Commit bb580da

Browse files
Fix AtomicObject::compareExchange. (#1244)
1 parent fd3e074 commit bb580da

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/hx/StdLibs.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,11 @@ struct AtomicObject: hx::Object {
522522
}
523523

524524
Dynamic compareExchange(Dynamic expected, Dynamic replacement) {
525-
hx::Object *original = aPtr.load();
525+
// Note: using Dynamic instead of hx::Object* is important
526+
// Dynamic has an overloaded == operator, a raw pointer to hx::Object does not.
527+
Dynamic original = aPtr.load();
526528
while (original == expected) {
527-
if (aPtr.compare_exchange_weak(original, replacement.mPtr)) {
529+
if (aPtr.compare_exchange_weak(original.mPtr, replacement.mPtr)) {
528530
HX_OBJ_WB_GET(this, replacement.mPtr);
529531
return original;
530532
} else {

0 commit comments

Comments
 (0)