-
Notifications
You must be signed in to change notification settings - Fork 115
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
tokio::io::* futures depend on details of std::io::Read and Write implementations #61
Comments
tokio::io::*
futures depend on details of std::io::Read
and Write
implementations
Thanks for the report! We discussed this yesterday and reached a similar conclusion as well. We're also thinking of adding a dependency on the |
Discussed with @dwrensha tonight and an important benefit of the current scheme which is that the traits are not connected to tokio-core but rather the standard library. The point was made that That may just mean that this crate is not the appropriate location for it, however and we could perhaps either add a new crate or add it to the |
To be more concrete, I would like capnp-futures-rust to continue not needing to depend on tokio-core. |
It's certainly not appropriate for tokio to have dependencies on tokio-specific implementation details of standard traits, so that just leaves making them an external crate. |
Yeah, I spent a lot of time trying to understand how loops work with P.S. What is the canonical way to read files now? |
I don't believe tokio currently supports file IO at all, though per this issue the type signatures confusingly suggest otherwise. If you're not building a high-performance database engine, you're likely best off implementing it with a threadpool. |
Just got bitten by this -- was really confused why nothing was being run. It would be nice have a warning in the docs like "if you use Ended up making a crate to work around this problem at the cost of cross-platform support. |
@aturon, @carllerche, and I discussed this the other day and our conclusions were to hit a few birds with one stone. In summary, we're thinking we'll:
I've begun prototyping this crate and have migrated tokio-core and tokio-tls as a proof of concept. Such a new crate is intended to close these issues:
The downside of this transition is "yet another crate", but the pros seem to outweigh the cons overall in this case. |
Could this somehow interact with |
Something to consider here is that this will make composing third-party Right now, I can plug a BzDecoder with a |
@Sid0 this will still be supported. It will require "lifting" the struct AsyncBzDecoder<T>(BzDecoder<T>); and then impl Hopefully this makes sense. |
Ah, I guess that shouldn't be too bad. Still possibly something to flag in the documentation though. |
As an update https://github.com/alexcrichton/tokio-io is nearing the 0.1 release (I've been commenting on a number of associated issues) and I plan on using this to track the migration. If you're interested in this (or associated issues) please feel free to take a look and report any issues you find! |
@alexcrichton I've noticed the Can you explain why you chose other approach? |
@carllerche may have more to say here as well. I think one aspect it covers is object safety? That is, a |
Yeah, object safety, less traits, and no need for specialization are valid reasons. |
Thank you! Can you explain why the function is unsafe to call? I'm unsure how it should work. (Maybe an example would help.) |
@Kixunil it's moreso unsafe to override rather than to call, so strictly speaking it's sort of just using |
@alexcrichton Thank you for explaining! I feel bit uneasy seeing it because AFAIK convention is that If you think that putting |
Oh yeah it's definitely not a "perfect" use of unsafe, but it hopefully gets the job done for now! I definitely agree the documentation should be quite thorough about why it's |
Ok! I've now published the |
…_buffer() As discussed in [tokio-rs#61 of tokio-core](tokio-rs/tokio-core#61 (comment)), documentation is added to explain the purpose of `unsafe` on this fn.
These futures call
std::io::Read
methods and expect them to internally register the task's interest in an event if it's not immediately ready. This isn't generally true for implementations ofRead
andWrite
implementations not based onPollEvented
. Tokio could introduce a newAsyncRead
andAsyncWrite
traits to make this requirement explicit.The text was updated successfully, but these errors were encountered: