[Php86] Polyfill the Io\Poll API#612
Open
nicolas-grekas wants to merge 1 commit into
Open
Conversation
fbdae99 to
7e4b509
Compare
Tracks https://wiki.php.net/rfc/poll_api for PHP 8.6. Requires PHP >= 8.1 (enums); only the Poll backend is available since the polyfill is backed by stream_select().
7e4b509 to
b1dd831
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracks the Polling API RFC targeted at PHP 8.6.
Surface added under
src/Php86/Resources/stubs/:Io\IoException,Io\Poll\PollException, abstractFailedPollOperationException(withERROR_*constants), and the seven specialized exceptions (Failed{ContextInitialization,HandleAdd,WatcherModification,PollWait}Exception,BackendUnavailableException,InactiveWatcherException,HandleAlreadyWatchedException,InvalidHandleException).Io\Poll\Backendenum withAuto,Poll,Epoll,Kqueue,EventPorts,WSAPollcases andisAvailable()/supportsEdgeTriggering()/getAvailableBackends().Io\Poll\Eventenum withRead,Write,Error,HangUp,ReadHangUp,OneShot,EdgeTriggered.Io\Poll\Handlemarker interface (annotated@internalto discourage userland implementations).Io\Poll\Context,Io\Poll\Watcher, and globalStreamPollHandle, with private constructors / not-serializable enforced via reboundClosures and throwing__serialize/__unserialize.Requires PHP >= 8.1 (enums). Backed by
stream_select(), so only thePollbackend is available;Autoresolves to it and the other backends throwBackendUnavailableException.HangUpdetection on sockets usesstream_socket_recvfrom(..., STREAM_PEEK)to non-destructively distinguish "readable with data" from "peer closed".35 unit tests cover the API surface and the event-detection logic.