예제 #1
0
파일: EioDriver.php 프로젝트: amphp/file
 /**
  * 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]);
 }
예제 #2
0
파일: EioDriver.php 프로젝트: staabm/file
 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]);
 }