Skip to content

RoutingCallbackPool

Quiote Routing Callback Pool - Reuses callback instances for performance This class maintains a pool of callback instances to avoid the overhead of creating new instances for each route match.

Particularly beneficial for complex routing configurations with many callbacks.

class RoutingCallbackPool implements ResetInterface

ImplementsResetInterface
SourceRouting/RoutingCallbackPool.php
MethodDescription
clearPool(): voidClear the callback pool
getInstance(string $className, array<string, mixed> $parameters = []): objectGet or create callback instance from pool
getPoolSize(): intGet current pool size
getResetInstance(): RoutingCallbackPoolGet reset instance for ResetInterface compliance
getStats(): array{pool_size: int, max_instances: int, access_count: int, memory_usage: int}Get pool statistics
removeInstance(string $className, array<string, mixed> $parameters = []): voidRemove specific instance from pool
reset(): voidReset callback pool state between requests in a persistent worker.
resetWorkerState(bool $preservePool = true, bool $resetStats = true): voidStatic method to reset worker state - called by WorkerManager
setMaxInstances(int $size): voidSet maximum pool size

public static function clearPool(): void

Clear the callback pool

public static function getInstance(string $className, array<string, mixed> $parameters = []): object

Get or create callback instance from pool

Callback parameters

ParameterTypeDescription
$classNamestringCallback class name
$parametersarray``<``string``, ``mixed``>Callback parameters

Returns object — Callback instance

public static function getPoolSize(): int

Get current pool size

Returns int — Number of pooled instances

public static function getResetInstance(): RoutingCallbackPool

Get reset instance for ResetInterface compliance

Returns RoutingCallbackPool

public static function getStats(): array{pool_size: int, max_instances: int, access_count: int, memory_usage: int}

Get pool statistics

Returns array{pool_size: int, max_instances: int, access_count: int, memory_usage: int} — Pool performance stats

public static function removeInstance(string $className, array<string, mixed> $parameters = []): void

Remove specific instance from pool

Callback parameters

ParameterTypeDescription
$classNamestringCallback class name
$parametersarray``<``string``, ``mixed``>Callback parameters

public function reset(): void

Reset callback pool state between requests in a persistent worker.

Called from the worker request boundary; see WorkerManager::resetForNextRequest(). In worker mode, we typically want to preserve pooled instances for performance, but reset statistics.

public static function resetWorkerState(bool $preservePool = true, bool $resetStats = true): void

Static method to reset worker state - called by WorkerManager

Whether to reset access statistics (default: true)

ParameterTypeDescription
$preservePoolboolWhether to preserve pooled instances (default: true)
$resetStatsboolWhether to reset access statistics (default: true)

public static function setMaxInstances(int $size): void

Set maximum pool size

Maximum number of pooled instances

ParameterTypeDescription
$sizeintMaximum number of pooled instances