in src/io/ReadHandleConvenienceMethodsTrait.php [22:60]
public async function readAllAsync(
?int $max_bytes = null,
?int $timeout_ns = null,
): Awaitable<string> {
_OS\arg_assert(
$max_bytes is null || $max_bytes > 0,
'Max bytes must be null, or > 0',
);
_OS\arg_assert(
$timeout_ns is null || $timeout_ns > 0,
'Timeout must be null, or > 0',
);
$to_read = $max_bytes ?? Math\INT64_MAX;
$data = '';
$timer = new \HH\Lib\_Private\OptionalIncrementalTimeout(
$timeout_ns,
() ==> {
_OS\throw_errno(
OS\Errno::ETIMEDOUT,
"Reached timeout before %s data could be read.",
$data === '' ? 'any' : 'all',
);
},
);
do {
$chunk_size = Math\minva($to_read, _IO\DEFAULT_READ_BUFFER_SIZE);
/* @lint-ignore AWAIT_IN_LOOP */
$chunk = await $this->readAllowPartialSuccessAsync(
$chunk_size,
$timer->getRemainingNS(),
);
$data .= $chunk;
$to_read -= Str\length($chunk);
} while ($to_read > 0 && $chunk !== '');
return $data;
}