コード例 #1
0
ファイル: DuplexPipe.php プロジェクト: icicleio/stream
 /**
  * {@inheritdoc}
  */
 public function end(string $data = '', float $timeout = 0) : \Generator
 {
     if (!$this->writable->isWritable()) {
         throw new UnwritableException('The stream is no longer writable.');
     }
     try {
         $written = (yield from $this->writable->end($data, $timeout));
     } finally {
         $this->readable->close();
     }
     return $written;
 }
コード例 #2
0
ファイル: Process.php プロジェクト: icicleio/concurrent
 /**
  * @coroutine
  *
  * @return \Generator
  *
  * @throws \Icicle\Concurrent\Exception\StatusError If the process has not been started.
  */
 public function join() : \Generator
 {
     if (null === $this->delayed) {
         throw new StatusError('The process has not been started.');
     }
     $this->poll->listen();
     try {
         return (yield $this->delayed);
     } finally {
         $this->stdout->close();
         $this->stderr->close();
     }
 }
コード例 #3
0
ファイル: Process.php プロジェクト: Nik-ADA/concurrent
    /**
     * @coroutine
     *
     * @return \Generator
     *
     * @throws \Icicle\Concurrent\Exception\StatusError If the process has not been started.
     */
    public function join()
    {
        if (null === $this->promise) {
            throw new StatusError('The process has not been started.');
        }

        $this->poll->reference();

        try {
            yield $this->promise;
        } finally {
            $this->stdout->close();
            $this->stderr->close();
        }
    }