/** * Returns the global worker pool for the current context. * * @param PoolInterface|null $pool A worker pool instance. * * @return PoolInterface The global worker pool instance. */ function pool(PoolInterface $pool = null) { static $instance; if (null !== $pool) { $instance = $pool; } elseif (null === $instance) { $instance = new Pool(); } if (!$instance->isRunning()) { $instance->start(); } return $instance; }