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;
}