SimpleObjectPool
class SimpleObjectPool extends ObjectPool
Properties
| protected Channel | $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 | $acquiring | from ObjectPool | |
| protected int | $creating | from ObjectPool | |
| protected Closure|null | $destroyCallback | from ObjectPool | |
| protected Closure | $callback |
Methods
Create a simple callback-backed object pool.
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.
Return the current number of objects managed by the pool.
Return the number of objects currently available in the pool.
Create a new object using the configured callback.
Assert an object is currently checked out from this pool.
Return an object to the idle channel without recording user activity.
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 $callback, PoolOptions $options, Closure|null $destroyCallback = null)
Create a simple callback-backed object pool.
in
ObjectPool at line 58
object
get()
Retrieve an object from the pool.
in
ObjectPool at line 82
void
release(object $object)
Release an object back to the pool.
in
ObjectPool at line 103
void
discard(object $object)
Destroy a checked-out object instead of returning it to the pool.
in
ObjectPool at line 114
void
sweepExpired()
Destroy idle objects that exceed the maximum lifetime.
in
ObjectPool at line 134
void
trimIdle()
Destroy idle objects past the maximum idle time down to the retention floor.
in
ObjectPool at line 162
void
close()
Close the pool and destroy all idle objects.
in
ObjectPool at line 179
bool
isClosed()
Determine if the pool is closed.
in
ObjectPool at line 187
bool
isIdle()
Determine if the entire pool has exceeded its idle TTL.
in
ObjectPool at line 198
int
getBorrowedObjectNumber()
Return the number of objects currently checked out.
in
ObjectPool at line 206
int
getCurrentObjectNumber()
Return the current number of objects managed by the pool.
in
ObjectPool at line 214
int
getObjectNumberInPool()
Return the number of objects currently available in the pool.
in
ObjectPool at line 222
PoolOptions
getOptions()
Get the normalized pool options.
in
ObjectPool at line 232
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 255
protected int
assertBorrowed(object $object)
Assert an object is currently checked out from this pool.
in
ObjectPool at line 273
protected void
requeue(object $object)
Return an object to the idle channel without recording user activity.
in
ObjectPool at line 281
protected void
destroyObject(object $object)
Destroy an object through the pool's single cleanup path.
in
ObjectPool at line 309
protected bool
exceedsMaxLifetime(object $object)
Determine if an object has exceeded its maximum lifetime.
in
ObjectPool at line 405
protected int
nanoseconds(float $seconds)
Convert seconds to nanoseconds without overflowing integer arithmetic.
in
ObjectPool at line 415
protected int
deadline(float $seconds)
Build a monotonic deadline without overflowing at long durations or uptimes.