Hello

> I expect that's already a good improvement for many use cases to read 
> multiple files in parallel, run multiple queries in parallel, etc.

I see. You want to get several promises to wait for?
Then there is a good way to do it without additional functions:

```php
$promise1 = spawn(file_get_content(...), "file1.txt");
$promise2 = spawn(file_get_content(...), "file2.txt");
$promise3 = spawn(file_get_content(...), "file3.txt");
```

This is equivalent because a coroutine is a Future. In the same way,
you can turn any other function into a Promise without creating a
separate API.

There is a nuance regarding resources. And in certain scenarios,
creating an array of Promises in another way can save memory. For
example, a scenario where you need to handle a large array of sockets.
Such cases require a special API.

---
Ed

Reply via email to