/** * @param String $name Unique name for the manager * @param array $config Config for the manager */ public function __construct($name, array $config = array()) { gc_enable(); $this->process = \Multitask\Process\Factory::getInstanceOsBased(); $this->spawner = new \Multitask\Spawner($this, $this->process); $this->workingDirectory = $this->pidFilename = $this->name = $name; $this->cache = new \Multitask\Cache(); if (isset($config['logger']) && $config['logger'] instanceof \Multitask\Log\Base) { $this->logger = $config['logger']; } else { $this->logger = new \Multitask\Log\Dummy(); } Error::setHandler($this->logger); Error::setName($name); foreach ($config as $key => $value) { if (array_key_exists($key, $this->config)) { $this->config[$key] = $value; } } if (!$this->config['filePath']) { $this->config['filePath'] = __DIR__ . '/Cache/'; } $this->fileHandler = new File($this->config['filePath']); if ($this->config['timeLimit'] !== false) { set_time_limit($this->config['timeLimit']); } if ($this->config['memoryLimit'] !== false) { ini_set('memory_limit', $this->config['memoryLimit']); } }
<?php require_once __DIR__ . '/../Multitask/Autoloader.php'; $test = \Multitask\Process\Factory::getInstance(); $test->setTitle('flap'); $test->getChildSignal(); sleep(4); var_dump($test);