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

Implementation of Extent Locals (Incubator)

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Provisional
    • Priority: P4
    • Resolution: Unresolved
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
      None
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      New API in incubator module, no compatibility impact.
    • Interface Kind:
      Java API
    • Scope:
      JDK

      Description

      This is the CSR for JEP xxx: Extents-local variables (Incubator) (JDK-8263012). The JEP is not currently on the technical roadmap and not targeted to any release at this time. For now, the fixVersion to set to "tbd". The @since tag on the new APIs is currently set to 19, this can be ignored.

      Summary

      Extent-local variables provide a way to share immutable data within threads and with child threads. They are preferred to thread-local variables, especially when using large numbers of virtual threads.

      Problem

      The Motivation section in the JEP explains some of the problems with the design of thread-local variables. These include unconstrained mutability, unbounded persistence, and expensive inheritance. These problems become more pressing in the context of virtual threads (JEP 424).

      Solution

      An extent-local variable is an instance of class ExtentLocal. It is a per-thread variable that allows context to be set in a caller and read by callees. Context can be anything from a business object to an instance of a system-wide logger. Unlike a thread-local variable, an extent-local variable is immutable: there is no set method.

      The term "extent-local" derives from the idea of an extent in the Java Virtual Machine Specification.

      The value associated with an extent-local variable is defined in the bottom most frame of some extent, and is accessible in every frame of that extent. The extent-local variable is bound to the value.

      The proposed API is in an incubator module, the module and package name proposed is jdk.incubator.concurrent.

      Specification

      A snapshot of the API docs is attached.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              aph Andrew Haley
              Reporter:
              alanb Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: