-
Notifications
You must be signed in to change notification settings - Fork 274
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
Consider using spawn
and channel
in specific async runtime.
#608
Comments
I agree that the underlying stream should not used to spawn a naked OS-thread outside any async runtime. The previous attempt to fix this seems to go back quite a while. I am willing to pick this up from here. However, I have a few questions before starting the rewrite.
|
No, sorry. Now I think that it is easy enough for the users of tokio or other async runtimes to write another stream without spawing new threads. |
Fair enough. |
I think it may be better to add some comments in the doc about the spawnned thread, and suggest the user to write a runtime-specific one if they care about the overhead. |
I can go ahead and add this fact to the docs about the type EvenStream. While I am at it, I would also add those comments to the example with tokio or asyn-std using this type. |
…Stream This pull request is motivated by the discussion of the following [issue](crossterm-rs#608)
…Stream This pull request is motivated by the discussion of the following [issue](crossterm-rs#608)
I see that
EventStream
is usingstd::thread
andstd::sync::mpsc
at now. It is of course an improvement according to #448. However, I'd like to suggest a possible improvement, with the usage ofspawn
andchannel
s in specific async runtime, for example,tokio
orasync-std
. Therefore, the async runtime could manage the event stream thread.The replacement in
tokio
isspawn
andmpsc
.The replacement in
async-std
isspawn
andchannel
.Both of them should be drop-in replacement, rewritting some functions to async ones. I'd like to open a pull request later, trying to add the implementation as an optional feature, and keep the original implementation as a fallback one.
The text was updated successfully, but these errors were encountered: