private function waitForStreamActivity($timeout)
{
$read = $this->readStreams;
$write = $this->writeStreams;
if ($this->streamSelect($read, $write, $timeout) === false) {
return;
}
foreach ($read as $stream) {
$key = (int) $stream;
if (isset($this->readListeners[$key])) {
$callable = $this->readListeners[$key];
$callable($stream, $this);
}
}
foreach ($write as $stream) {
$key = (int) $stream;
if (isset($this->writeListeners[$key])) {
$callable = $this->writeListeners[$key];
$callable($stream, $this);
}
}
}