crossterm
crossterm copied to clipboard
Expose Mio internals in public API
I am writing an application in which I need to poll for an event at the same time as reading user input. I could do this with two threads: one calling event::read() and one in a Mio loop of the second thread and my event, but it would be far more efficient if Crossterm exposed an implementation of Mio's Source in its event module so I could use just 1 thread.
This should obviously come after the update to Mio 0.7.
I've implemented a similar design by having different streams (one of which is crossterm's EventStream) and futures::select between them. If mio is only included in Unix, I'm not really sure how exposing it would work (given that crossterm exposes a cross-platform API).
Mio does support Windows. Currently Crossterm uses just Mio internally for both its EventStream (where each EventStream spawns another thread to run the Mio loop and notify the Waker) and its poll and read.
Mio is only used for unix systems. Windows uses winapi for reading events.
We can fix this issue in #435. Though @mcobzarenco is right that when donig this we are going to make the API inconsistent.
From Mio's Readme:
Currently supported platforms:
Android DragonFly BSD FreeBSD Linux NetBSD OpenBSD Solaris Windows iOS macOS
It uses Wepoll's strategy to achieve poll-based IO on Windows.
Mio is going to be removed soon. #735