Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Mio internals in public API #441

Open
Kestrer opened this issue Jun 7, 2020 · 6 comments
Open

Expose Mio internals in public API #441

Kestrer opened this issue Jun 7, 2020 · 6 comments

Comments

@Kestrer
Copy link
Contributor

Kestrer commented Jun 7, 2020

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.

@mcobzarenco
Copy link

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

@Kestrer
Copy link
Contributor Author

Kestrer commented Jun 29, 2020

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.

@TimonPost
Copy link
Member

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

@TimonPost
Copy link
Member

TimonPost commented Jun 29, 2020

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

@Kestrer
Copy link
Contributor Author

Kestrer commented Jun 29, 2020

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.

@TimonPost
Copy link
Member

Mio is going to be removed soon. #735

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants