Package com.oracle.truffle.api
Class ContextThreadLocal<T>
java.lang.Object
com.oracle.truffle.api.ContextThreadLocal<T>
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
ModifierConstructorDescriptionprotected
ContextThreadLocal
(Object polyglotObject) Custom subclasses of context local are not allowed. -
Method Summary
Modifier and TypeMethodDescriptionabstract 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.
-
Constructor Details
-
ContextThreadLocal
Custom subclasses of context local are not allowed.- Since:
- 20.3
-
-
Method Details
-
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 nevernull
. ThrowsIllegalStateException
if no current context is entered on the current thread.- Since:
- 20.3
-
get
Returns the context thread local value for the currently entered context and the given thread. This method is less efficient thanget()
orget(TruffleContext)
as it requires synchronization between the threads. The return value is nevernull
. ThrowsIllegalStateException
if no current context is entered on the current thread.- Since:
- 20.3
-
get
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 nevernull
. ThrowsIllegalStateException
if no current context is entered on the current thread.- Since:
- 20.3
-
get
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 thanget()
orget(TruffleContext)
as it requires synchronization between the threads. The return value is nevernull
. ThrowsIllegalStateException
if no current context is entered on the current thread.- Since:
- 20.3
-