Re: PHP True Async RFC Stage 4

From: Date: Tue, 21 Oct 2025 14:56:25 +0000
Subject: Re: PHP True Async RFC Stage 4
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-128881@lists.php.net to get a copy of this message
> This seems a bit contradictory and confuses things. When I await(), do I need to do it in a
> loop, or just once?
> It might be a good idea to make a couple subtypes: Signal and Future. Coroutines become Future
> that only await once, while Signal is something that can be awaited many times.

I made a mistake in my previous response, and it requires clarification.
Classes that can be awaited multiple times are indeed possible.
These include TimeInterval, Channel, FileSystemEvent, as well
as
I/O triggers.

All of these classes can be Awaitable.
This is done to allow bulk waiting on objects, regardless of how they
work internally.
So this is meant for functions like awaitXX, although such behavior
is also possible for the await() function itself:

```php
$timeInterval = new Async\TimeInterval(1000);
while(true) {
    await($timeInterval);
}
```

As for objects of type Future, it’s clear that in future RFCs there
will be a FutureInterface, which will be implemented by coroutines.


Thread (104 messages)

« previous php.internals (#128881) next »