Method
Pool::__construct
Creates an empty pool; instances are made when they are needed.
Description#
public Pool::__construct(
Closure $create,
int $size,
?float $window = null,
?Closure $dispose = null
)Parameters#
- $create Closure
- Makes an instance, in the borrowing coroutine, so it may wait
- $size int
- The most instances in existence at once
- $window ?float = null
- Seconds to look back for the peak number of instances lent at once, which the pool shrinks to; null never shrinks
- $dispose ?Closure = null
- Called with each instance the pool lets go of, to close or flush it
Errors / Exceptions#
| Exception | When |
|---|---|
InvalidArgumentException | If $size is below 1, or $window is not above 0 |