Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8367013

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

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • hotspot
    • None

      Lock-free code in HotSpot uses an idiom of declaring variables `volatile` and using operations from the `Atomic` class to access and modify those variables. It would be better to package that idiom, preventing accidental misuse such as using non-atomic read-modify-write arithmetic operations on such variables.

      The proposal is to add `Atomic<T>`, where `T` is a supported atomic type as before. Then incrementally replace (most) uses of that idiom with uses of this new type. "Most" because it is expected there will be some small residue where use of the `Atomic<T>` class isn't appropriate. One example is BitMap, which provides some atomic operations but where it would not be appropriate to change the underlying data to be an array of `Atomic<bm_word_t>`.

            kbarrett Kim Barrett
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: