public function install(\XPSPL\Process $process)
{
if (XPSPL_DEBUG) {
logger(XPSPL_LOG)->debug(sprintf('%s process install', $process));
}
$priority = $process->get_priority();
if ($this->offsetExists($priority)) {
if ($this->offsetGet($priority) instanceof Processes) {
if (XPSPL_DEBUG) {
logger(XPSPL_LOG)->debug(sprintf('%s sub-database root', $this->offsetGet($priority)));
logger(XPSPL_LOG)->debug(sprintf('%s next priority', $this->offsetGet($priority)->end()->get_priority() + 1));
}
$process->set_priority($this->offsetGet($priority)->end()->get_priority() + 1);
$this->offsetGet($priority)->install($process);
} else {
if (XPSPL_DEBUG) {
logger(XPSPL_LOG)->debug(sprintf('%s create sub-database', $this->offsetGet($priority)));
}
$this->offsetGet($priority)->set_priority(XPSPL_SUBDATABASE_DEFAULT_PRIORITY);
$db = new Processes();
$db->install($this->offsetGet($priority));
$this->offsetUnset($priority);
$this->offsetSet($priority, $db);
$this->install($process);
}
} else {
if (XPSPL_DEBUG) {
// var_dump($this->_storage);
logger(XPSPL_LOG)->debug(sprintf('%s process installed NODE_COUNT(%s)', $process, $this->count()));
}
// var_dump($priority);
// var_dump($process);
$this->_storage[$priority] = $process;
}
}