blockingEval

Evaluates expr by borrowing an evaluator from the pool, blocking the current thread until one is available and recycling it afterwards.

The pool is a bounded buffer of size evaluators, so this blocks when all are in use and waits for one to be recycled. Do not call it more than size times concurrently, or from a context that already holds the pool's only evaluator, or it can deadlock.

The expression runs on the calling thread and cannot be stopped once it starts, so an expression that never finishes blocks this thread, and holds its evaluator, for good. Use the overload that takes a timeout for expressions that might not finish.

Return

the boolean result of the evaluation

Parameters

expr

the expression to evaluate

Throws

if the expression fails

if the calling thread is interrupted while it waits for an evaluator


fun blockingEval(expr: String, timeout: Duration): Boolean

Like blockingEval, but runs the expression on a thread of its own and fails with a ScriptTimeoutException if it does not finish within timeout. See eval with a timeout; the wait for an evaluator does not count toward timeout.

Return

the boolean result of the evaluation

Parameters

expr

the expression to evaluate

timeout

how long the expression may run; must be positive

Throws

if the expression does not finish within timeout


fun blockingEval(expr: String, timeout: Duration): Boolean

blockingEval with a timeout given as a java.time.Duration, for Java callers: the overload taking a Kotlin Duration cannot be called from Java.

Return

the boolean result of the evaluation

Parameters

expr

the expression to evaluate

timeout

how long the expression may run; must be positive

Throws

if the expression does not finish within timeout

if the expression fails

if the calling thread is interrupted while it waits