public final class FastThreadLocalFactory extends Object
int
(class
FastThreadLocalInt
), primitive long
(class FastThreadLocalLong
),
Object
(class FastThreadLocalObject
), and word
(class
FastThreadLocalWord
) values. Access to such thread local variables is significantly
faster than regular Java ThreadLocal
variables. However, there are several restrictions:
IsolateThread
data structure would not be a compile time constant.
null
for every newly created
thread. There is no possibility to specify an initial value.
static final
field. The name of that field is used as the name of the local variable. The name is used to sort
the variables in the IsolateThread
data structure, to make the layout deterministic and
reproducible.
static final
field, which is the intended
use case.
The implementation of fast thread local variables and the way the data is stored is implementation specific and transparent for users of it. However, the access is fast and never requires object allocation.
Modifier and Type | Method and Description |
---|---|
static <T extends org.graalvm.word.PointerBase> |
createBytes(IntSupplier sizeSupplier)
Creates a new fast thread local memory block that has a user-defined size.
|
static FastThreadLocalInt |
createInt()
Creates a new fast thread local variable of the primitive type
int . |
static FastThreadLocalLong |
createLong()
Creates a new fast thread local variable of the primitive type
long . |
static <T> FastThreadLocalObject<T> |
createObject(Class<T> valueClass)
Creates a new fast thread local variable of type
Object . |
static <T extends org.graalvm.word.WordBase> |
createWord()
Creates a new fast thread local variable of type
word . |
public static FastThreadLocalInt createInt()
int
.public static FastThreadLocalLong createLong()
long
.public static <T extends org.graalvm.word.WordBase> FastThreadLocalWord<T> createWord()
word
.public static <T> FastThreadLocalObject<T> createObject(Class<T> valueClass)
Object
.public static <T extends org.graalvm.word.PointerBase> FastThreadLocalBytes<T> createBytes(IntSupplier sizeSupplier)