Skip to content

JavaWrapper ​

com.jsmacrosce.jsmacros.graal.library.impl.FWrapper

Since1.2.5

Note: re-named from consumer in 1.4.0

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 ​

methodToJava(Value c): MethodWrapper<A, B, R, GraalScriptContext>Since1.3.2#
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 argument
  • B: type of the second callback argument
  • R: callback result type
Returns: wrapper that invokes c and returns its result

methodToJavaAsync ​

methodToJavaAsync(Value c): MethodWrapper<A, B, R, GraalScriptContext>Since1.3.2#
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.

Parameters:

  • c: executable script function

Type Parameters:

  • A: type of the first callback argument
  • B: type of the second callback argument
  • R: 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.

Parameters:

  • priority: queue priority used to order callback execution
  • c: executable script function

Type Parameters:

  • A: type of the first callback argument
  • B: type of the second callback argument
  • R: callback result type
Returns: wrapper that schedules void callbacks, with their failures logged; result-returning calls run synchronously

stop ​

stop(): voidSince1.2.2#
Closes the current script context, including its Graal context.