JsEnginePool class

Bounded pool of JavascriptRuntime instances for multi-engine workloads.

Engines are created lazily up to maxSize. Call acquire / release, or use withEngine. Always dispose the pool when finished.

Default JsEnginePoolConfig.resetMode is EngineResetMode.none (warm reuse). Use EngineResetMode.soft or EngineResetMode.hard (or resetOnRelease: true) when tenants must not share globalThis / channels.

Constructors

JsEnginePool({int maxSize = 4, JsEnginePoolConfig config = const JsEnginePoolConfig(), JavascriptRuntime factory()?})

Properties

config JsEnginePoolConfig
final
disposeCount int
no setter
hashCode int
The hash code for this object.
no setterinherited
idleCount int
no setter
idleEngines List<JavascriptRuntime>
Engines that can be inspected without taking part in pool scheduling. Diagnostic callers must only read engine state, never evaluate on them.
no setter
inUseCount int
no setter
maxSize int
final
resetCount int
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size int
no setter

Methods

acquire({Duration? timeout}) Future<JavascriptRuntime>
Borrow an engine. Blocks (async) if all engines are in use until one is released, unless timeout elapses.
dispose() → void
Dispose all engines and fail any pending acquire waiters.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
release(JavascriptRuntime engine) → void
Return an engine to the pool. Do not use engine after this call.
toString() String
A string representation of this object.
inherited
withEngine<T>(FutureOr<T> fn(JavascriptRuntime runtime), {Duration? acquireTimeout}) Future<T>
Run fn with a borrowed engine, always releasing afterward.

Operators

operator ==(Object other) bool
The equality operator.
inherited