summaryrefslogtreecommitdiff
path: root/unix/moduselect.c
AgeCommit message (Collapse)Author
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-03-05unix/moduselect: Properly implement ipoll object iteration.Paul Sokolovsky
TODO: There's another issue to care about: poll set being modified during iteration.
2017-02-16py: Add iter_buf to getiter type method.Damien George
Allows to iterate over the following without allocating on the heap: - tuple - list - string, bytes - bytearray, array - dict (not dict.keys, dict.values, dict.items) - set, frozenset Allows to call the following without heap memory: - all, any, min, max, sum TODO: still need to allocate stack memory in bytecode for iter_buf.
2017-02-13unix/moduselect: Implement ipoll() method with no-allocation policy.Paul Sokolovsky
ipoll() allows to poll streams without allocating any memory: this method returns an iterator (a poll object itself), and the iterator yields preallocated "callee-owned tuple" with polling results for each active stream. The only operation a caller is allowed to do with this tuple is extracting values from it (storing the tuple as a whole somewhere is not allowed).
2016-12-31unix/moduselect: Fix nanbox build with recent changes.Paul Sokolovsky
2016-12-31unix/moduselect: If file object passed to .register(), return it in .poll().Paul Sokolovsky
This makes unix "uselect" compatible with baremetal "uselect". Previosuly, unix version accepted file/socket objects, but internally converted that to file descriptors, and that's what .poll() returned. To acheive new behavior, file-like objects are stored internally in an array, in addition to existing array of struct pollfd. This array is created only on first case of file-like object being passed to .register(). If only raw fd's are passed, there will be no additional memory used comparing to the original implementation.
2016-11-21unix: Rename define for unix moduselect to MICROPY_PY_USELECT_POSIX.Paul Sokolovsky
To not conflict with recently made available globally baremetal moduselect.
2016-10-07unix: Use mp_raise_OSError helper function.Damien George
2016-09-22all: Remove 'name' member from mp_obj_module_t struct.Damien George
One can instead lookup __name__ in the modules dict to get the value.
2016-09-12unix: Fix build for when MICROPY_PY_SOCKET=0.Renato Aguiar
2016-08-07unix/moduselect: Allow poll.register(), etc. accept fd-like objects.Paul Sokolovsky
This includes file and socket objects, backed by Unix file descriptor. This improves compatibility with stmhal's uselect (and convenience of use), though not completely: return value from poll.poll() is still raw file descriptor.
2016-01-11py: Change type signature of builtin funs that take variable or kw args.Damien George
With this patch the n_args parameter is changed type from mp_uint_t to size_t.
2016-01-03py: Change struct and macro for builtin fun so they can be type checked.Damien George
2015-12-13unix/moduselect: Make configurable with MICROPY_PY_USELECT.Paul Sokolovsky
2015-12-11unix/moduselect: Implement "one-shot" flag for poll.poll().Paul Sokolovsky
After an I/O event is triggered for fd, event flags are automatically reset, so no further events are reported until new event flags are set. This is an optimization for uasyncio, required to account for coroutine semantics: each coroutine issues explicit read/write async call, and once that trigger, no events should be reported to coroutine, unless it again explicitly requests it. One-shot mode saves one linear scan over the poll array.
2015-12-05unix/moduselect: register(): Allow to call with duplicate file descriptor.Paul Sokolovsky
Per CPython docs, "Registering a file descriptor that’s already registered is not an error, and has the same effect as registering the descriptor exactly once." https://docs.python.org/3/library/select.html#select.poll.register That's somewhat ambiguous, what's implemented here is that if fd si not yet registered, it is registered. Otherwise, the effect is equivalent to modify() method.
2015-11-30unix/moduselect: Support growing of poll array.Paul Sokolovsky
2015-11-29py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.Damien George
This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
2015-11-29py: Add MP_ROM_* macros and mp_rom_* types and use them.Damien George
2015-11-29unix/moduselect: poll.register(): Reuse freed entries in poll array.Paul Sokolovsky
2015-11-28unix/moduselect: Fix bug in poll.poll() scanning loop.Paul Sokolovsky
2015-11-20unix/moduselect: Initialise variable so can compile in non-debug mode.Damien George
2015-11-17unix: Add "uselect" module, with poll() function.Paul Sokolovsky
Underlyingly, uses standard POSIX poll() for portability.