/** * {@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); }
/** * {@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; }
/** * {@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; }
/** * {@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; }
/** * {@inheritdoc} */ public function create(callable $callback, array $args = []) : ImmediateInterface { $immediate = $this->factory->immediate($this, $callback, $args); $this->execute($immediate); return $immediate; }