Hi,

On Sun, Nov 23, 2025 at 4:05 PM Tim Düsterhus <[email protected]> wrote:

> Hi
>
> Apologies for the late reply. It was a few busy weeks leading up to the
> PHP 8.5 Release.
>
> When searching for the RFC text I just noticed that it does not appear
> to be listed in https://wiki.php.net/rfc#under_discussion yet.
>
>
This is fixed.


>
> >
> >> As an example PollContext::__construct() should probably throw a
> >> BackendUnavailableException or something like this. For
> >> PollContext::add() I'm wondering in which cases a handle “cannot be
> >> added”.
> >
> >
> > It fails if the same fd is added. This is also limitation of backends
> (e.g.
> > epoll does not allow the same fd to be added twice). I got error code for
> > the specific errors so this should be probably exposed as well. It would
> > still make sense to differentiate that it's an exception for addition.
>
> I see. I was wondering if it would make sense to simply ignore the
> error, thus making the operation idempotent (more convenient for a
> high-level language like PHP). But I suppose that doesn't work, because
> the `$data` could be different?
>
>
Yeah data and events can be different.


> Exception-wise this should probably be a DuplicateHandleError (i.e.
> within the Error hierarchy, since it's a programming error to add
> duplicate handles).
>
>
I don't think users should be expected to keep track of added handles. So I
think that this is something that can be nicely handled and in some cases
it will be just fine to just catch it and ignore. So I wouldn't see this as
a programmer error and therefore the exception is more appropriate IMHO. I
created a specific exception for this called
\Io\Poll\HandleAlreadyWatchedException so it will be easy for users to
differentiate it.

Kind regards,

Jakub

Reply via email to