コード例 #1
0
ファイル: SocketManager.php プロジェクト: kanzuka/icicle
 /**
  * {@inheritdoc}
  */
 public function create($resource, callable $callback) : SocketEventInterface
 {
     $id = (int) $resource;
     if (isset($this->sockets[$id])) {
         throw new ResourceBusyError('A socket event has already been created for this resource.');
     }
     return $this->sockets[$id] = $this->factory->socket($this, $resource, $callback);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function create(int $signo, callable $callback, array $args = []) : SignalInterface
 {
     if (!isset($this->signals[$signo])) {
         throw new InvalidSignalError(sprintf('Invalid signal number: %d.', $signo));
     }
     $signal = $this->factory->signal($this, $signo, $callback);
     $this->signals[$signo]->attach($signal);
     return $signal;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function create($resource, callable $callback) : SocketEventInterface
 {
     $id = (int) $resource;
     if (isset($this->events[$id])) {
         throw new ResourceBusyError('A poll has already been created for that resource.');
     }
     $socket = $this->factory->socket($this, $resource, $callback);
     $event = $this->loop->io($resource, $this->type, $this->socketCallback, $socket);
     $event->stop();
     $this->events[$id] = $event;
     return $socket;
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function create(float $interval, bool $periodic, callable $callback, array $args = []) : TimerInterface
 {
     $timer = $this->factory->timer($this, $interval, $periodic, $callback, $args);
     $this->start($timer);
     return $timer;
 }
コード例 #5
0
ファイル: ImmediateManager.php プロジェクト: kanzuka/icicle
 /**
  * {@inheritdoc}
  */
 public function create(callable $callback, array $args = []) : ImmediateInterface
 {
     $immediate = $this->factory->immediate($this, $callback, $args);
     $this->execute($immediate);
     return $immediate;
 }