buffer = $buffer; $this->notifier = $notifier; } public function shutdown() : void{ $this->shutdown = true; } public function quit() : void{ $wait = microtime(true) + 0.5; while(microtime(true) < $wait){ if($this->isRunning()){ usleep(100000); }else{ parent::quit(); return; } } throw new ThreadException("CommandReader is stuck in a blocking STDIN read"); } protected function onRun() : void{ $buffer = $this->buffer; $notifier = $this->notifier; $reader = new CommandReader(); while(!$this->shutdown){ $line = $reader->readLine(); if($line !== null){ $buffer[] = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", $line); if($notifier !== null){ $notifier->wakeupSleeper(); } } } } public function getThreadName() : string{ return "Console"; } }