/** * {@inheritdoc} */ protected function dispatch(bool $blocking) { $timeout = $blocking ? $this->timerManager->getInterval() : 0; // Use stream_select() if there are any streams in the loop. if (!$this->pollManager->isEmpty() || !$this->awaitManager->isEmpty()) { $seconds = (int) $timeout; $microseconds = ($timeout - $seconds) * self::MICROSEC_PER_SEC; $read = $this->pollManager->getPending(); $write = $this->awaitManager->getPending(); $except = null; // Error reporting suppressed since stream_select() emits an E_WARNING if it is interrupted by a signal. $count = @stream_select($read, $write, $except, null === $timeout ? null : $seconds, $microseconds); if ($count) { $this->pollManager->handle($read); $this->awaitManager->handle($write); } } elseif (0 < $timeout) { // Otherwise sleep with usleep() if $timeout > 0. usleep($timeout * self::MICROSEC_PER_SEC); } $this->timerManager->tick(); // Call any pending timers. }