GraalScriptContext
com.jsmacrosce.jsmacros.graal.language.impl.GraalScriptContext
Holds the runtime context and task queue for a Graal script. Scripts obtain it from the context global:
js
const ctx = context.getCtx();
Chat.log(ctx.isMultiThreaded());Constructors
new GraalScriptContext
Fields
tasks
Live per-context queue of wrapped threads, ordered using their stored priorities.
Methods
closeContext
closeContext(): void#Releases bound event locks, interrupts bound threads and unregisters this context through base cleanup, then calls
close(true) on the assigned Graal runtime if present.closeContext(boolean preventLog): void#Closes this context and sets whether the execution wrapper suppresses its cancellation log.
Parameters:
preventLog: whether to suppress the cancellation log
getThreadPriority
isMultiThreaded
isMultiThreaded(): boolean#Reports that this context does not advertise concurrent execution on multiple threads.
Returns:
false because this context does not advertise concurrent executionsetMainThread
wrapSleep
wrapSleep(BaseScriptContext.SleepRunnable sleep): void#Runs a potentially blocking operation through the task-queue scheduling path without changing its priority.
Parameters:
sleep: operation that may block and throwInterruptedException
wrapSleep(int changePriority, BaseScriptContext.SleepRunnable sleep): void#Leaves the Graal runtime, polls the queue head and signals the next entry, if present, before running the operation. After the operation, a new wrapper for the calling thread is enqueued with the polled entry's stored priority plus
changePriority, using Java integer arithmetic. It waits if the queue head then belongs to another thread. Runtime re-entry is attempted in the outer finally block after a successful leave. This requires an assigned, entered runtime and a suitable queue head; the method does not verify that the polled entry belongs to the caller. If the operation or wait is interrupted, this method does not remove the newly enqueued entry.Parameters:
changePriority: adjustment added to the polled entry's stored priority for the new entrysleep: operation to run while the runtime is left; it may block and throwInterruptedException