public function onWriteEv($bev)
{
$this->writing = false;
if ($this->finished) {
if ($this->bev->output->length === 0) {
$this->close();
}
return;
}
if (!$this->ready) {
$this->ready = true;
while (!$this->onWriteOnce->isEmpty()) {
try {
$this->onWriteOnce->executeOne($this);
} catch (\Exception $e) {
Daemon::uncaughtExceptionHandler($e);
}
if (!$this->ready) {
return;
}
}
$this->alive = true;
try {
$this->onReady();
if ($this->wRead) {
$this->wRead = false;
$this->onRead();
}
} catch (\Exception $e) {
Daemon::uncaughtExceptionHandler($e);
}
} else {
$this->onWriteOnce->executeAll($this);
}
try {
$this->onWrite();
} catch (\Exception $e) {
Daemon::uncaughtExceptionHandler($e);
}
}