Interop\Async\Loop::disable PHP Method

disable() public static method

Disabling a watcher MUST NOT invalidate the watcher. Calling this function MUST NOT fail, even if passed an invalid watcher.
public static disable ( string $watcherId ) : void
$watcherId string The watcher identifier.
return void
    public static function disable($watcherId)
    {
        $driver = self::$driver ?: self::get();
        $driver->disable($watcherId);
    }

Usage Example

Example #1
0
 protected function createReadWatcher() : callable
 {
     return function ($id) {
         while (!$this->pendingReads->isEmpty()) {
             $read = $this->pendingReads->bottom();
             if ($read->disabled) {
                 $this->pendingReads->dequeue();
                 continue;
             }
             $len = \strlen($this->readBuffer);
             try {
                 $chunk = $this->fillReadBuffer($len, $read->length);
             } catch (\Throwable $e) {
                 $this->readerEnabled = false;
                 Loop::disable($id);
                 while (!$this->pendingReads->isEmpty()) {
                     $this->pendingReads->dequeue()->fail($e);
                 }
                 return;
             }
             if ($chunk === $this) {
                 return;
             }
             if ($chunk === null) {
                 $this->readerEnabled = false;
                 Loop::disable($id);
                 while (!$this->pendingReads->isEmpty()) {
                     $this->pendingReads->dequeue()->resolve(null);
                 }
                 return;
             }
             $read = $this->pendingReads->dequeue();
             if ($len > $read->length) {
                 $this->readBuffer = \substr($chunk, $read->length);
                 $read->resolve(\substr($chunk, 0, $read->length));
             } else {
                 $this->readBuffer = '';
                 $read->resolve($chunk);
             }
         }
         $this->readerEnabled = false;
         Loop::disable($id);
     };
 }
All Usage Examples Of Interop\Async\Loop::disable