Re:Atomics and Concurrency
by dataflow on Sunday June 01, 2025 @03:04AM
(#44149139)
Wait, what? How would you translate the Java code I wrote to C++ then?
[ Parent
| on HN ]
Re:Atomics and Concurrency
by charleslmunger on Sunday June 01, 2025 @05:32PM
(#44153883)
You can't precisely convert it to c++, because there's no c++ construct that precisely matches Java behavior - namely atomic with relaxed memory order but permitting aliasing and load/store optimizations. The spiritually closest thing would just be a regular variable, which would be a data race that tsan would catch.
You can go the other way, porting that c++ to Java using varhandle and opaque memory order.