MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / compareExchange

Method compareExchange

include/hx/StdLibs.h:534–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

532 }
533
534 Dynamic compareExchange(Dynamic expected, Dynamic replacement) {
535 // Note: using Dynamic instead of hx::Object* is important
536 // Dynamic has an overloaded == operator, a raw pointer to hx::Object does not.
537 Dynamic original = aPtr.load();
538 while (original == expected) {
539 if (aPtr.compare_exchange_weak(original.mPtr, replacement.mPtr)) {
540 HX_OBJ_WB_GET(this, replacement.mPtr);
541 return original;
542 } else {
543 continue;
544 }
545 }
546 return original;
547 }
548};
549
550inline Dynamic __hxcpp_atomic_object_create(Dynamic value) {

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected