Example #1
0
 /**
  * {@inheritdoc}
  */
 public function listen(SocketEventInterface $socket, float $timeout = 0)
 {
     $resource = $socket->getResource();
     $id = (int) $resource;
     if (!isset($this->sockets[$id]) || $socket !== $this->sockets[$id]) {
         throw new FreedError('Poll has been freed.');
     }
     $this->pending[$id] = $resource;
     if ($timeout) {
         if (self::MIN_TIMEOUT > $timeout) {
             $timeout = self::MIN_TIMEOUT;
         }
         $this->timers[$id] = $this->loop->timer($timeout, false, $this->timerCallback, [$socket]);
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function listen(Io $io, float $timeout = 0)
 {
     $resource = $io->getResource();
     $id = (int) $resource;
     if (!isset($this->sockets[$id]) || $io !== $this->sockets[$id]) {
         throw new FreedError();
     }
     $this->pending[$id] = $resource;
     if ($timeout) {
         if (self::MIN_TIMEOUT > $timeout) {
             $timeout = self::MIN_TIMEOUT;
         }
         $this->timers[$id] = $this->loop->timer($timeout, false, $this->timerCallback, [$io]);
     }
 }