Method
Pool::use
Runs $fn with an instance of its own, and releases the instance afterwards, also when $fn throws.
Description#
public Pool::use(
Closure $fn,
float $timeout = PHP_FLOAT_MAX
): mixedCall discard() inside $fn if the instance broke.
Parameters#
- $fn Closure
- What to run with the instance
- $timeout float = PHP_FLOAT_MAX
- Seconds to wait for an instance at most
Return values#
What $fn returned mixed
Errors / Exceptions#
| Exception | When |
|---|---|
TimeoutException | If no instance became free in time |
Throwable | What $create or $fn threw |
See also#
Pool::borrowLends an instance to the caller until it callsrelease()ordiscard(), and waits while all are out.