Let extensions accept Io\Poll\Handle objects - #23810
nicolas-grekas wants to merge 1 commit into
Conversation
php_poll.h exports php_poll_handle_get_fd() and the handle object struct, but not the class entry of the interface, so an extension cannot check that an object is a handle before running PHP_POLL_HANDLE_OBJ_FROM_ZV() on it without looking the class up by name. Export the entry and a resolver for parameters that accept more than a handle. php_poll_handle_default_ops was declared without PHPAPI, so an extension providing its own handle type could not link it on Windows.
b26aaa3 to
40f3a6b
Compare
|
It might be too late for this and I'd rather not expose it yet for other extensions. It's specifically meant for the poll API at this stage. |
|
Just to clarify the reason here - it's because I plan to introduce some other handle types for 8.7 and I would like to make sure that the internal API is consistent because not all of them will support fd's so it might need a bit of considering to make sure that things are right. |
|
Works for me. Note that it seams ext-ev / ext-event might be dead and while ext-uv might be well supported, I don't know maintainer's plan for 8.6 (see amphp/ext-uv#120 & amphp/ext-uv#121) |
|
ext-ev / ext-event are not dead, see rosmanov/pecl-ev#1 :) |
php_poll.hexportsphp_poll_handle_get_fd()and the handle object struct under "utility functions for extensions", but not the class entry ofIo\Poll\Handle, so an extension cannot check that an object is a handle before runningPHP_POLL_HANDLE_OBJ_FROM_ZV()on it, other than by looking the class up by name. This exports the entry, plus a resolver for the common case of a parameter that takes more than a handle:What it is for: ext-ev, ext-event and ext-uv could then take an
Io\Poll\Handlewhere they take a stream or a descriptor today, resolve it in C and keep a reference to the handle while they watch it, so a handle provided by an extension works with the event loops that are notIo\Poll. That is the alternative to handing the descriptor to userland, which is what #23792 removes.php_poll_handle_default_opswas declared withoutPHPAPItoo, so an extension providing its own handle type cannot link it on Windows./cc @bukka