public abstract class VMThreads extends Object
IsolateThreads.| Modifier and Type | Class and Description |
|---|---|
static class |
VMThreads.StatusSupport
A thread-local enum giving the thread status of a VMThread.
|
| Modifier and Type | Field and Description |
|---|---|
static FastThreadLocalWord<org.graalvm.nativeimage.Isolate> |
IsolateTL |
static VMCondition |
THREAD_LIST_CONDITION
A condition variable for waiting for and notifying on changes to the
IsolateThread
list. |
static VMMutex |
THREAD_MUTEX
A mutex for operations on
IsolateThreads. |
| Constructor and Description |
|---|
VMThreads() |
| Modifier and Type | Method and Description |
|---|---|
abstract org.graalvm.nativeimage.IsolateThread |
allocateIsolateThread(int isolateThreadSize)
Allocate native memory for a
IsolateThread. |
void |
attachThread(org.graalvm.nativeimage.IsolateThread thread)
Creates a new
IsolateThread and adds it to the list of running threads. |
static void |
detachThread(org.graalvm.nativeimage.IsolateThread current)
Remove a
IsolateThread from the list of VMThreads. |
static void |
detachThreads(org.graalvm.nativeimage.IsolateThread[] threads) |
static boolean |
ensureInitialized()
Make sure the runtime is initialized for threading.
|
abstract void |
failFatally(int code,
org.graalvm.nativeimage.c.type.CCharPointer message)
Report a fatal error to the user and exit.
|
org.graalvm.nativeimage.IsolateThread |
findIsolateThreadforCurrentOSThread() |
static org.graalvm.nativeimage.IsolateThread |
firstThread()
Iteration of all
IsolateThreads that are currently running. |
abstract void |
freeIsolateThread(org.graalvm.nativeimage.IsolateThread thread)
Free the native memorry allocated by
VMThreads.allocateIsolateThread(int). |
protected abstract org.graalvm.word.ComparableWord |
getCurrentOSThreadId() |
protected abstract boolean |
initializeOnce()
Invoked exactly once early during the startup of an isolate.
|
static boolean |
isInitialized() |
static boolean |
isNonNullThread(org.graalvm.nativeimage.IsolateThread vmThread)
A predicate for the
non-null IsolateThread. |
static boolean |
isNullThread(org.graalvm.nativeimage.IsolateThread vmThread)
A predicate for the
null IsolateThread. |
static boolean |
isTearingDown()
Is threading being torn down?
|
static org.graalvm.nativeimage.IsolateThread |
nextThread(org.graalvm.nativeimage.IsolateThread cur)
Iteration of all
IsolateThreads that are currently running. |
static org.graalvm.nativeimage.IsolateThread |
nullThread()
The value of a
null IsolateThread. |
protected static void |
setTearingDown()
Note that threading is being torn down.
|
static VMThreads |
singleton() |
public static final VMMutex THREAD_MUTEX
IsolateThreads.public static final VMCondition THREAD_LIST_CONDITION
IsolateThread
list.public static final FastThreadLocalWord<org.graalvm.nativeimage.Isolate> IsolateTL
public static VMThreads singleton()
public static boolean isInitialized()
public static boolean isTearingDown()
protected static void setTearingDown()
public static boolean ensureInitialized()
protected abstract boolean initializeOnce()
public abstract org.graalvm.nativeimage.IsolateThread allocateIsolateThread(int isolateThreadSize)
IsolateThread. The returned memory must be initialized
to 0.public abstract void freeIsolateThread(org.graalvm.nativeimage.IsolateThread thread)
VMThreads.allocateIsolateThread(int).public abstract void failFatally(int code,
org.graalvm.nativeimage.c.type.CCharPointer message)
public static org.graalvm.nativeimage.IsolateThread nullThread()
null IsolateThread.public static boolean isNullThread(org.graalvm.nativeimage.IsolateThread vmThread)
null IsolateThread.public static boolean isNonNullThread(org.graalvm.nativeimage.IsolateThread vmThread)
non-null IsolateThread.public static org.graalvm.nativeimage.IsolateThread firstThread()
IsolateThreads that are currently running. VMThreads.THREAD_MUTEX
should be held when iterating the list.
Use the following pattern to iterate all running threads. It is allocation free and can
therefore be used during GC:
for (VMThread thread = VMThreads.firstThread(); VMThreads.isNonNullThread(thread); thread = VMThreads.nextThread(thread)) {
public static org.graalvm.nativeimage.IsolateThread nextThread(org.graalvm.nativeimage.IsolateThread cur)
IsolateThreads that are currently running. See
VMThreads.firstThread() for details.public void attachThread(org.graalvm.nativeimage.IsolateThread thread)
IsolateThread and adds it to the list of running threads. This method
must be the first method called in every thread.public static void detachThread(org.graalvm.nativeimage.IsolateThread current)
IsolateThread from the list of VMThreads. This method must be the last
method called in every thread.public static void detachThreads(org.graalvm.nativeimage.IsolateThread[] threads)
protected abstract org.graalvm.word.ComparableWord getCurrentOSThreadId()
public org.graalvm.nativeimage.IsolateThread findIsolateThreadforCurrentOSThread()