JavaWrapper
com.jsmacrosce.jsmacros.graal.library.impl.FWrapper
Wraps script callbacks for use as Java MethodWrappers through the JavaWrapper library.
Graal contexts are entered by one thread at a time. Calls through these wrappers are coordinated by a priority queue; asynchronous wrappers schedule void callbacks on the script thread pool,
while calls that need a result run synchronously.
Accessible in scripts via the global JavaWrapper variable.
Methods
deferCurrentTask
deferCurrentTask(): void#Yields the current script task while the supplied sleep operation runs, then rejoins the queue at its existing priority.
deferCurrentTask(int priorityAdjust): void#Yields the current script task while the supplied sleep operation runs, then rejoins the queue with an adjusted priority.
Parameters:
priorityAdjust: amount added to the current task priority
getCurrentPriority
getCurrentPriority(): int#Returns: the current script task's queue priority
methodToJava
Wraps a callable for Java use; each wrapper call executes the script function synchronously and returns its result.
Parameters:
c: executable script function
Type Parameters:
A: type of the first callback argumentB: type of the second callback argumentR: callback result type
Returns: wrapper that invokes
c and returns its resultmethodToJavaAsync
Wraps a callable for Java use. Calls that only need the callback to run, such as
accept and run, are scheduled on the script thread pool and return immediately; their failures are logged. Calls that need a result, such as apply, test, get, and compare, run synchronously on the caller and return or throw the result. A scheduled callback joins the script queue from the pool worker that runs it, so two callbacks submitted by one script may start in either order. Priority decides which queued callback runs next; it does not make separate submissions start in submission order.Parameters:
c: executable script function
Type Parameters:
A: type of the first callback argumentB: type of the second callback argumentR: callback result type
Returns: wrapper that schedules void callbacks and runs result-returning calls synchronously
methodToJavaAsync(int priority, Value c): MethodWrapper<A, B, R, ?>#Wraps a callable for asynchronous execution with an explicit queue priority. The other asynchronous overloads use priority 5. As with the no-priority form, only void callbacks are scheduled; calls that need a result run synchronously. Priority orders callbacks that are already queued; it does not order the submissions that put them there.
Parameters:
priority: queue priority used to order callback executionc: executable script function
Type Parameters:
A: type of the first callback argumentB: type of the second callback argumentR: callback result type
Returns: wrapper that schedules void callbacks, with their failures logged; result-returning calls run synchronously
stop
Closes the current script context, including its Graal context.