AbstractExprEvaluatorPool
Abstract base class for a pool of AbstractExprEvaluator instances.
Each evaluator's context is reset once it has been returned resetEvery times, so engine state such as Kotlin's REPL history cannot grow without bound. Resetting is not free: a fresh Kotlin REPL costs several times an evaluation, so resetting on every return would make the pool slower than a lone evaluator. Between resets, a declaration an expression makes (such as val y = 1 inside run { }) stays visible to the evaluator's later borrowers. Subclasses populate the pool with populate in their init block. AbstractEnginePool describes borrowing and closing.
Parameters
the number of evaluator instances in the pool; must be positive
how many times an evaluator is returned between resets of its context; 1 resets on every return
Type Parameters
the concrete type of AbstractExprEvaluator managed by this pool
Throws
if size or resetEvery is not positive
Functions
Evaluates expr by borrowing an evaluator from the pool, blocking the current thread until one is available and recycling it afterwards.