Наследование: implements Icicle\Concurrent\Worker\WorkerInterface
Пример #1
0
 public function __construct()
 {
     parent::__construct(new Thread(function () {
         $runner = new TaskRunner($this, new Environment());
         yield $runner->run();
     }));
 }
Пример #2
0
 /**
  * @param string $operation
  * @param int $value
  *
  * @return \Generator
  *
  * @throws \Icicle\File\Exception\FileException
  */
 private function change(string $operation, int $value) : \Generator
 {
     if (!$this->isOpen()) {
         throw new FileException('The file has been closed.');
     }
     try {
         return yield from $this->worker->enqueue(new Internal\FileTask($operation, [$this->path, $value]));
     } catch (TaskException $exception) {
         $this->close();
         throw new FileException(sprintf('%s failed.', $operation), $exception);
     }
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function kill()
 {
     $this->worker->kill();
 }
Пример #4
0
 public function __construct()
 {
     $dir = dirname(dirname(__DIR__)) . '/bin';
     parent::__construct(new ChannelledProcess($dir . '/worker.php', $dir));
 }