Beispiel #1
0
 /**
  * {@inheritDoc}
  */
 public function disable($watcherId)
 {
     if (!isset($this->watchers[$watcherId])) {
         return;
     }
     $watcher = $this->watchers[$watcherId];
     if (!$watcher->isEnabled) {
         return;
     }
     $watcher->isEnabled = false;
     $this->keepAliveCount -= $watcher->keepAlive;
     switch ($watcher->type) {
         case Watcher::IO_READER:
             // fallthrough
         // fallthrough
         case Watcher::IO_WRITER:
             $this->disablePollFromWatcher($watcher);
             break;
         case Watcher::SIGNAL:
             \uv_signal_stop($watcher->uvHandle);
             break;
         case Watcher::IMMEDIATE:
             unset($this->immediates[$watcherId]);
             break;
         case Watcher::TIMER_ONCE:
             // fallthrough
         // fallthrough
         case Watcher::TIMER_REPEAT:
             \uv_timer_stop($watcher->uvHandle);
             break;
         default:
             throw new \RuntimeException("Unexpected Watcher type encountered");
     }
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 protected function disableSignalWatcher(SignalWatcher $watcher, bool $dispose = false)
 {
     if ($watcher->event === null) {
         return;
     }
     unset($this->signalWatchers[$watcher->signo][$watcher->id]);
     if (empty($this->signalWatchers[$watcher->signo])) {
         unset($this->signalWatchers[$watcher->signo]);
         if (\uv_is_active($watcher->event)) {
             \uv_signal_stop($watcher->event);
         }
     }
     if ($dispose) {
         try {
             if ($this->dispatching) {
                 $this->dispose->enqueue($watcher->event);
             } else {
                 \uv_close($watcher->event);
             }
         } finally {
             $watcher->event = null;
         }
     }
 }
 /**
  * @codeCoverageIgnore
  */
 public function __destruct()
 {
     foreach ($this->sigHandles as $sigHandle) {
         \uv_signal_stop($sigHandle);
     }
 }