/** * 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]); }
private function createPoll() : Io { return Loop\poll(\eio_get_event_stream(), function () { while (\eio_npending()) { \eio_poll(); } }, true); }
public function __construct() { if (self::$eio === null) { \eio_init(); $eio = @\eio_get_event_stream(); \stream_set_blocking($eio, false); \stream_set_read_buffer($eio, 0); self::$eio = $eio; self::$callback = function () { while (\eio_npending()) { \eio_poll(); } }; } }
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]); }
public function workPendingCount() { return eio_nreqs() + eio_npending() + eio_nready(); }