phasync
Pool / borrow

Method

Pool::borrow

Lends an instance to the caller until it calls release() or discard(), and waits while all are out.

Description#

public Pool::borrow(
    float $timeout = PHP_FLOAT_MAX
): object

Parameters#

$timeout float = PHP_FLOAT_MAX
Seconds to wait for an instance at most

Return values#

An instance that no other coroutine has object

Errors / Exceptions#

ExceptionWhen
TimeoutExceptionIf no instance became free in time
ThrowableWhat $create threw

See also#

  • Pool::useRuns $fn with an instance of its own, and releases the instance afterwards, also when $fn throws.
  • Pool::releaseGives a borrowed instance back, for the next borrower.