Interop\Async\Loop::reference PHP Method

reference() public static method

This will keep the event loop alive whilst the watcher is still being monitored. Watchers have this state by default.
public static reference ( string $watcherId ) : void
$watcherId string The watcher identifier.
return void
    public static function reference($watcherId)
    {
        $driver = self::$driver ?: self::get();
        $driver->reference($watcherId);
    }

Usage Example

Example #1
0
 public function referenceReader(bool $reference)
 {
     if ($reference) {
         if ($this->readerEnabled && !$this->readerReferenced) {
             Loop::reference($this->readWatcher);
         }
     } else {
         if ($this->readerEnabled && $this->readerReferenced) {
             Loop::unreference($this->readWatcher);
         }
     }
     $this->readerReferenced = $reference;
 }