release method
void
release(
- T resource
Returns resource to the pool. A waiting borrower (if any) receives it
directly; otherwise it becomes idle. After close, the resource is simply
dropped from the count (not disposed here — see close).
Audited: 2026-06-12 11:26 EDT
Implementation
void release(T resource) {
if (_isClosed) {
// Pool is shut down: drop the resource from the live count. Disposal is
// not performed here because this method is synchronous and cannot await a
// disposer. The close method disposes the idle resources it holds, while a
// resource still checked out at shutdown belongs to the caller — return
// resources before closing, or dispose that one directly.
_created--;
return;
}
if (_waiters.isNotEmpty) {
_waiters.removeAt(0).complete(resource);
return;
}
_idle.add(resource);
}