/** * We have to keep a static reference of eio event streams * because if we don't garbage collection can unload eio's * underlying pipe via a system close() call before it's * finished and generate a SIGPIPE. */ public function __construct() { if (empty(self::$stream)) { \eio_init(); self::$stream = \eio_get_event_stream(); } $this->callableDecrementor = function () { \call_user_func($this->incrementor, -1); }; $this->incrementor = function ($increment) { switch ($increment) { case 1: case -1: $this->pending += $increment; break; default: throw new FilesystemException("Invalid pending event increment; 1 or -1 required"); } if ($this->pending === 0) { \Amp\disable($this->watcher); } elseif ($this->pending === 1) { \Amp\enable($this->watcher); } }; $this->watcher = \Amp\onReadable(self::$stream, function () { while (\eio_npending()) { \eio_poll(); } }, $options = ["enable" => false]); }
public function __construct() { if (empty(self::$isEioInitialized)) { \eio_init(); self::$isEioInitialized = true; } $this->stream = \eio_get_event_stream(); $this->callableDelReq = function () { $this->decrementPending(); }; $this->internalIncrement = function () { $this->incrementPending(); }; $this->internalDecrement = function () { $this->decrementPending(); }; $this->watcher = \Amp\onReadable($this->stream, function () { while (\eio_npending()) { \eio_poll(); } }, $options = ["enable" => false]); }