AbstractScriptPool

abstract class AbstractScriptPool<T : AbstractScript>(val size: Int, nullGlobalContext: Boolean)

Abstract base class for a pool of AbstractScript instances.

Uses a coroutine Channel as a bounded buffer to manage script engine instances. When a script is returned to the pool, its context is automatically reset. Subclasses are responsible for populating the pool in their init block.

Parameters

size

the number of script instances in the pool

nullGlobalContext

if true, resets the global scope bindings to null when recycling

Type Parameters

T

the concrete type of AbstractScript managed by this pool

Constructors

Link copied to clipboard
constructor(size: Int, nullGlobalContext: Boolean)

Properties

Link copied to clipboard

Returns an approximate, point-in-time indication of whether the pool currently has no script instances available. Delegates to Channel.isEmpty, which is racy under concurrent borrow/recycle and may return a stale result, so do not rely on it for correctness.

Link copied to clipboard
val size: Int

Functions

Link copied to clipboard
suspend fun <R> eval(block: T.() -> R): R