pixelfederation/swoole-bundle

View on GitHub
src/Bridge/Symfony/Container/ServicePool/ServicePoolContainer.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types=1);

namespace K911\Swoole\Bridge\Symfony\Container\ServicePool;

final class ServicePoolContainer
{
    /**
     * @param array<ServicePool<object>> $pools
     */
    public function __construct(private array $pools)
    {
    }

    /**
     * @param ServicePool<object> $pool
     */
    public function addPool(ServicePool $pool): void
    {
        $this->pools[] = $pool;
    }

    public function releaseFromCoroutine(int $cId): void
    {
        foreach ($this->pools as $pool) {
            $pool->releaseFromCoroutine($cId);
        }
    }

    public function count(): int
    {
        return count($this->pools);
    }
}