Class ContextThreadLocal<T>

java.lang.Object
com.oracle.truffle.api.ContextThreadLocal<T>

public abstract class ContextThreadLocal<T> extends Object
A context thread local reference that refers to a value that is created for each polyglot context and thread. Context thread references can be used to attach data to a polyglot context for a thread. That data can be retrieved efficiently for the current context and thread using get() or less efficiently for other contexts and other threads using get(TruffleContext, Thread). Context thread locals can be created for languages and instruments. See links below for usage examples.
Since:
20.3
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ContextThreadLocal(Object polyglotObject)
    Custom subclasses of context local are not allowed.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract T
    get()
    Returns the context thread local value for the currently entered context and thread.
    abstract T
    Returns the context thread local value for the given context and the current thread.his method is intended to be used on compiled code paths.
    abstract T
    get(TruffleContext context, Thread t)
    Returns the context thread local value for the given context and the given thread.
    abstract T
    Returns the context thread local value for the currently entered context and the given thread.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ContextThreadLocal

      protected ContextThreadLocal(Object polyglotObject)
      Custom subclasses of context local are not allowed.
      Since:
      20.3
  • Method Details

    • get

      public abstract T get()
      Returns the context thread local value for the currently entered context and thread. This method is intended to be used on compiled code paths. The return value is never null. Throws IllegalStateException if no current context is entered on the current thread.
      Since:
      20.3
    • get

      public abstract T get(Thread t)
      Returns the context thread local value for the currently entered context and the given thread. This method is less efficient than get() or get(TruffleContext) as it requires synchronization between the threads. The return value is never null. Throws IllegalStateException if no current context is entered on the current thread.
      Since:
      20.3
    • get

      public abstract T get(TruffleContext t)
      Returns the context thread local value for the given context and the current thread.his method is intended to be used on compiled code paths. The return value is never null. Throws IllegalStateException if no current context is entered on the current thread.
      Since:
      20.3
    • get

      public abstract T get(TruffleContext context, Thread t)
      Returns the context thread local value for the given context and the given thread. The context does not need to, but may be entered when retrieving the current context local. This method is less efficient than get() or get(TruffleContext) as it requires synchronization between the threads. The return value is never null. Throws IllegalStateException if no current context is entered on the current thread.
      Since:
      20.3