RFR: 8367013: Add Atomic<T> to package/replace idiom of volatile var plus AtomicAccess:: operations

Albert Mingkun Yang ayang at openjdk.org
Mon Oct 6 10:22:07 UTC 2025


On Sat, 4 Oct 2025 01:07:23 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> Yes, which is why I said "roughly like."

OK, I understand the reasoning behind the naming. However, I’d argue that the design feels somewhat *inside-out* — it exposes implementation details through the abstraction.

Returning to the example of `atomic_store_explicit` vs. `atomic_thread_fence` in C++, they are two distinct sets of APIs with different specifications and semantics. Mixing them only introduces unnecessary confusion.  
The corresponding APIs in HotSpot are `Atomic::release_store` and `OrderAccess::release`, and drawing parallels between them can also be misleading.

A more accurate way to view `Atomic::release_store` is that the memory synchronization is *intrinsically tied* to the `store` operation — not before it, not after it. (Also, I wonder if using an arg, i.e. `store(mo_release)`, similar to what's in C++, can avoid the confusion of viewing `store` and `release` as two separate steps.)

> And on some platforms it might be "exactly like", because that's how it's implemented for that platform.

That’s merely an implementation detail, which shouldn’t be reflected at the specification level (or in the naming).

-------------

PR Comment: https://git.openjdk.org/jdk/pull/27539#issuecomment-3370902620


More information about the hotspot-dev mailing list