CallbackObjectPool
class CallbackObjectPool extends ObjectPool
Properties
| protected T> | $channel | from ObjectPool | |
| protected array<int, true> | $managed | from ObjectPool | |
| protected array<int, true> | $borrowed | from ObjectPool | |
| protected array<int, int> | $creationTimes | from ObjectPool | |
| protected array<int, int> | $releaseTimes | from ObjectPool | |
| protected int | $lastUsedAt | from ObjectPool | |
| protected bool | $closed | from ObjectPool | |
| protected int | $acquiringCount | from ObjectPool | |
| protected int | $creatingCount | from ObjectPool | |
| protected Closure|null | $destroyCallback | from ObjectPool | |
| protected Closure | $createCallback |
Methods
Create an object pool using a construction callback.
Destroy a checked-out object instead of returning it to the pool.
Destroy idle objects past the maximum idle time down to the retention floor.
Create a new object using the configured callback.
Ensure an object is currently checked out from this pool.
Return an object to the idle channel without recording activity, or destroy it when the pool has closed.
Destroy an object through the pool's single cleanup path.
Determine if an object has exceeded its maximum lifetime.
Convert seconds to nanoseconds without overflowing integer arithmetic.
Build a monotonic deadline without overflowing at long durations or uptimes.
Details
at line 16
__construct(callable $createCallback, PoolOptions $options, Closure|null $destroyCallback = null)
Create an object pool using a construction callback.
in
ObjectPool at line 63
object
borrow()
Borrow an object from the pool.
in
ObjectPool at line 89
void
release(object $object)
Release an object back to the pool.
in
ObjectPool at line 110
void
discard(object $object)
Destroy a checked-out object instead of returning it to the pool.
in
ObjectPool at line 121
void
sweepExpired()
Destroy idle objects that exceed the maximum lifetime.
in
ObjectPool at line 141
void
trimIdle()
Destroy idle objects past the maximum idle time down to the retention floor.
in
ObjectPool at line 169
void
close()
Close the pool and destroy all idle objects.
in
ObjectPool at line 195
bool
isClosed()
Determine if the pool is closed.
in
ObjectPool at line 203
bool
isIdleExpired()
Determine if the entire pool has exceeded its idle timeout.
in
ObjectPool at line 214
int
getBorrowedCount()
Return the number of objects currently checked out.
in
ObjectPool at line 222
int
getManagedCount()
Return the current number of objects managed by the pool.
in
ObjectPool at line 230
int
getIdleCount()
Return the number of objects currently available in the pool.
in
ObjectPool at line 238
int
getWaitingCount()
Return the number of coroutines waiting for an object.
in
ObjectPool at line 246
PoolOptions
getOptions()
Get the normalized pool options.
in
ObjectPool at line 256
array
getStats()
Return statistics about the pool's current state.
at line 29
protected object
createObject()
Create a new object using the configured callback.
in
ObjectPool at line 280
protected int
ensureBorrowed(object $object)
Ensure an object is currently checked out from this pool.
in
ObjectPool at line 300
protected void
requeue(object $object)
Return an object to the idle channel without recording activity, or destroy it when the pool has closed.
in
ObjectPool at line 311
protected void
destroyObject(object $object)
Destroy an object through the pool's single cleanup path.
in
ObjectPool at line 341
protected bool
exceedsMaxLifetime(object $object)
Determine if an object has exceeded its maximum lifetime.
in
ObjectPool at line 437
protected int
nanoseconds(float $seconds)
Convert seconds to nanoseconds without overflowing integer arithmetic.
in
ObjectPool at line 447
protected int
deadline(float $seconds)
Build a monotonic deadline without overflowing at long durations or uptimes.