PHPDaemon\Network\Pool::getInstance PHP Method

getInstance() public static method

Returns instance object
public static getInstance ( string $arg = '', boolean $spawn = true ) : this
$arg string name / array config / ConfigSection
$spawn boolean Spawn? Default is true
return this
    public static function getInstance($arg = '', $spawn = true)
    {
        if ($arg === 'default') {
            $arg = '';
        }
        $class = get_called_class();
        if (is_string($arg)) {
            $key = $class . ':' . $arg;
            if (isset(self::$instances[$key])) {
                return self::$instances[$key];
            } elseif (!$spawn) {
                return false;
            }
            $k = '\\PHPDaemon\\Core\\Pool:\\' . $class . ($arg !== '' ? ':' . $arg : '');
            $config = isset(Daemon::$config->{$k}) && Daemon::$config->{$k} instanceof Config\Section ? Daemon::$config->{$k} : new Config\Section();
            $obj = self::$instances[$key] = new $class($config);
            $obj->name = $arg;
        } elseif ($arg instanceof Config\Section) {
            $obj = new static($arg);
        } else {
            $obj = new static(new Config\Section($arg));
        }
        $obj->eventLoop = EventLoop::$instance;
        return $obj;
    }