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

Kim Barrett kbarrett at openjdk.org
Mon Sep 29 12:09:10 UTC 2025


On Mon, 29 Sep 2025 11:45:51 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> Personally, I've never liked `Atomic::load` and `Atomic::store` either.

I've always thought it's weird that for most AtomicAccess operations, the
short form (defaulted memory order) provides the strongest ordering, but the
short form of load/store is the weakest form.

If we were to be more like std::atomic we'd have

load(memory_order_relaxed)
load(memory_order_acquire)
store(memory_order_relaxed)
store(memory_order_release)

(And std::atomic doesn't have release_store_fence?)
And there I'd agree the visual cues for the distinctions are not great.
But we're not doing that, and I don't think we should.

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

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


More information about the hotspot-dev mailing list