0) { if ($this->channel instanceof Channel) { $this->channel->pop(); } return; } if ($this->wait === false) { return; } while ($this->wait === true) { usleep(1000); } } /** * @return void */ public function wait(): void { Coroutine::getCid() > 0 ? $this->channel = new Channel(1) : $this->wait = true; } /** * @return void */ public function done(): void { if (Coroutine::getCid() > 0) { $this->channel?->push(true); $this->channel->close(); $this->channel = null; } else { $this->wait = false; } } }