Atomics.compareExchange() should advise reading the returned value #28049
Labels
Content:JS
JavaScript docs
help wanted
If you know something about this topic, we would love your help!
MDN URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/compareExchange
What specific section or headline is this issue about?
No response
What information was incorrect, unhelpful, or incomplete?
I think the documentation for Atomics.compareExchange() should strongly advise users to check the returned value to learn if the exchange has happened or not. The sample code could also reflect that.
What did you expect to see?
A strong encouragement to read the result value and learn if the exchange happened, maybe an explanation as to what makes it a synchronization primitive, because at face value it might look like a random operation.
Do you have any supporting links, references, or citations?
https://en.wikipedia.org/wiki/Compare-and-swap#Example_application:_atomic_adder
Do you have anything more you want to share?
thank you for your work!
MDN metadata
Page report details
en-us/web/javascript/reference/global_objects/atomics/compareexchange
The text was updated successfully, but these errors were encountered: