Redefine UnsupportedFeatureException to be only thrown if the system
doesn't support the feature. Drivers MUST support it if PCNTL or something
similar is available.
The LoopDriverFactory SHOULD be used by driver implementations
to set a default event loop driver.
This can be achieved by having a Composer autoloader like that:
{
"autoload": {
"files": ["src/bootstrap.php"]
}
}
Where src/bootstrap.php contains the following code:
use Interop\Async\EventLoop\LoopDriverFactory;
class MyDriverFactory implements LoopDriverFactory
{
public function create()
{
return new MyDriver();
}
}
Loop::setFactory(new MyDriverFactory());
This ensures the user doesn't have to care about setting the actual
driver. A user just has to require the specific event loop driver
package he / she wants to use.
Previously this code allowed multiple error handlers. This change
would allow for only a single error handler that is overwritten by
future calls and can be cleared by passing a null parameter.
The registry allows to store information bound to a specific loop.
This can be useful to store state of globals like a DNS resolver.
Rationale for a global DNS resolver:
Nobody wants to inject a resolver into everything that does some sort of I/O.
Using IP addresses everywhere instead of hostnames also doesn't make sense.
Therefore there should be a global default DNS resolver. But this resolver
needs a read watcher for the response. If the loop gets swapped and a DNS
request is made, the resolver would never get the read event, since the
stream is only watched in the old loop. The resolver also doesn't get any
info about the loop swap, so it can't use a new watcher.
With a loop bound registry, it can just store the connection in the loop and
will use a new connection when the loop is swapped, because the state doesn't
exist any longer. Once the loop is put back, it can use the old connection
again.
This API should only be used by real global objects. Most packages won't need
to use this API, but it's required for the mentioned use cases.