On Thu, Mar 20, 2025, at 12:01, Edmond Dantes wrote:
> ```php
> spawn fn() => [file_get_content(), file_get_content(), file_get_content()]
> ```
This example highlights one of the concerns I have with fibers and this approach in general. That
example will still execute synchronously, taking file_get_contents() * 3, even though it is in a
coroutine function.
If you wanted to make it asynchronous, you'd have to do something like so:
$x = [spawn fn() => file_get_contents($a), spawn fn() => file_get_contents($b), spawn fn()
=> file_get_contents($c)];
foreach($x as $i => $spawn) $x[$i] = await $spawn;
That is quite a bit more work than I'd like just to get async file reading done.
— Rob