AbstractExprEvaluatorPool

Abstract base class for a pool of AbstractExprEvaluator instances.

Uses a coroutine Channel as a bounded buffer to manage evaluator instances. Subclasses are responsible for populating the pool in their init block.

Parameters

size

the number of evaluator instances in the pool

Type Parameters

T

the concrete type of AbstractExprEvaluator managed by this pool

Constructors

Link copied to clipboard
constructor(size: Int)

Properties

Link copied to clipboard

Returns an approximate, point-in-time indication of whether the pool currently has no evaluators 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

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

Link copied to clipboard
suspend fun eval(expr: String): Boolean

Suspends until an evaluator can be borrowed from the pool, evaluates expr, and recycles the evaluator afterwards. Suspends (rather than blocking) when all size evaluators are in use.