watcher = Loop::onReadable(self::$stream, function () { while (\eio_npending()) { \eio_poll(); } }); Loop::disable($this->watcher); } public function listen() { if ($this->requests++ === 0) { Loop::enable($this->watcher); } } public function done() { if (--$this->requests === 0) { Loop::disable($this->watcher); } } public function __destruct() { Loop::cancel($this->watcher); } }