circuitpython/ports
Damien George ef71028f77 extmod/modselect: Add optimisation to use system poll when possible.
A previous commit removed the unix-specific select module implementation
and made unix use the common one.

This commit adds an optimisation so that the system poll function is used
when polling objects that have a file descriptor.  With this optimisation
enabled, if code registers both file-descriptor-based objects, and non-
file-descriptor-based objects with select.poll() then the following occurs:

- the system poll is called for all file-descriptor-based objects with a
  timeout of 1ms

- then the bare-metal polling implementation is used for remaining objects,
  which calls into their ioctl method (which can be in C or Python)

In the case where all objects have file descriptors, the system poll is
called with the full timeout requested by the caller.  That makes it as
efficient as possible in the case everything has a file descriptor.

Benefits of this approach:

- all ports use the same select module implementation

- the unix port now supports polling of all objects and matches bare metal
  implementations

- it's still efficient for existing cases where only files and sockets are
  polled (on unix)

- the bare metal implementation does not change

- polling of SSL objects will now work on unix by calling in to the ioctl
  method on SSL objects (this is required for asyncio ssl support)

Note that extmod/vfs_posix_file.c has poll disable when the optimisation is
enabled, because the code is not reachable when the optimisation is used.

Signed-off-by: Damien George <damien@micropython.org>
2023-08-07 12:11:40 +10:00
..
bare-arm bare-arm/mpconfigport.h: Disable remaining optional features. 2021-11-01 14:23:06 +11:00
cc3200 extmod/moddeflate: Add deflate module providing the DeflateIO class. 2023-07-21 19:32:40 +10:00
embed all: Rename *umodule*.c to remove the "u" prefix. 2023-06-08 17:54:17 +10:00
esp32 esp32/README: Specify that only IDF v5.0.2 is supported. 2023-07-25 12:59:02 +10:00
esp8266 esp8266/machine_pin: Accept an integer argument to mp_obj_get_pin_obj. 2023-07-20 17:33:54 +10:00
mimxrt py/mpconfig: Add MICROPY_PY_PLATFORM, enabled at extra features level. 2023-07-24 23:53:20 +10:00
minimal all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
nrf extmod/asyncio: Rename uasyncio to asyncio. 2023-06-19 17:33:03 +10:00
pic16bit ports: Implement simple write polling for stdout. 2023-03-23 13:51:17 +11:00
powerpc all: Fix spelling mistakes based on codespell check. 2023-04-27 18:03:06 +10:00
qemu-arm extmod/moddeflate: Add deflate module providing the DeflateIO class. 2023-07-21 19:32:40 +10:00
renesas-ra py/mpconfig: Add MICROPY_PY_PLATFORM, enabled at extra features level. 2023-07-24 23:53:20 +10:00
rp2 rp2/machine_pin: Factor out pin-find code from machine_pin_make_new. 2023-07-20 17:30:17 +10:00
samd extmod/moddeflate: Add deflate module providing the DeflateIO class. 2023-07-21 19:32:40 +10:00
stm32 py/mpconfig: Add MICROPY_PY_PLATFORM, enabled at extra features level. 2023-07-24 23:53:20 +10:00
teensy ports: Standardise docs link in help text. 2023-06-02 11:48:46 +10:00
unix extmod/modselect: Add optimisation to use system poll when possible. 2023-08-07 12:11:40 +10:00
webassembly webassembly: Replace typeof window check with ENVIRONMENT_IS_NODE flag. 2023-07-13 13:24:35 +10:00
windows extmod/moddeflate: Add deflate module providing the DeflateIO class. 2023-07-21 19:32:40 +10:00
zephyr py/mkrules.mk: Automatically configure frozen options when manifest set. 2023-06-08 23:12:56 +10:00