/** * {@inheritdoc} */ protected function activate(array $watchers) { foreach ($watchers as $watcher) { if (!isset($this->events[$id = $watcher->id])) { switch ($watcher->type) { case Watcher::READABLE: $this->events[$id] = $this->handle->io($watcher->value, \Ev::READ, $this->ioCallback, $watcher); break; case Watcher::WRITABLE: $this->events[$id] = $this->handle->io($watcher->value, \Ev::WRITE, $this->ioCallback, $watcher); break; case Watcher::DELAY: case Watcher::REPEAT: $interval = $watcher->value / self::MILLISEC_PER_SEC; $this->events[$id] = $this->handle->timer($interval, $watcher->type & Watcher::REPEAT ? $interval : 0, $this->timerCallback, $watcher); break; case Watcher::SIGNAL: $this->events[$id] = $this->handle->signal($watcher->value, $this->signalCallback, $watcher); break; default: throw new \DomainException("Unknown watcher type"); } } else { $this->events[$id]->start(); } } }
/** * {@inheritdoc} */ protected function enableSignalWatcher(SignalWatcher $watcher) { if ($watcher->event === null) { $watcher->event = $this->loop->signal($watcher->signo, $this->signalCallback, $watcher); } else { $watcher->event->start(); } }