crossterm icon indicating copy to clipboard operation
crossterm copied to clipboard

Expose Mio internals in public API

Open Kestrer opened this issue 5 years ago • 6 comments

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.

Kestrer avatar Jun 07 '20 15:06 Kestrer

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).

mcobzarenco avatar Jun 28 '20 22:06 mcobzarenco

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.

Kestrer avatar Jun 29 '20 05:06 Kestrer

Mio is only used for unix systems. Windows uses winapi for reading events.

TimonPost avatar Jun 29 '20 05:06 TimonPost

We can fix this issue in #435. Though @mcobzarenco is right that when donig this we are going to make the API inconsistent.

TimonPost avatar Jun 29 '20 05:06 TimonPost

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.

Kestrer avatar Jun 29 '20 06:06 Kestrer

Mio is going to be removed soon. #735

TimonPost avatar Jan 11 '23 20:01 TimonPost