async-tungstenite icon indicating copy to clipboard operation
async-tungstenite copied to clipboard

Generic solution to AsyncRead as std::io::Read

Open najamelan opened this issue 6 years ago • 4 comments

I just ran into this: https://crates.io/crates/async-stdio

It's only in an alpha release, I haven't scrutinized it, but if it's good, it's probably worth for tokio-tungstenite, async-tungstenite and potentially other (I thought tokio had the same issue somewhere) to re-use a generic solution to this problem rather than handrolling code for this in several places.

najamelan avatar Mar 11 '20 16:03 najamelan

Yeah I like the idea and already saw that crate a few weeks ago. Once it's stable, I think we can move over to it. Back then I didn't see anything obviously wrong there.

One thing that might be a problem from our side is that we need to be able to have up to two wakers per read/write operation (reading a ping will cause a pong to be sent, so you can have a waker from your read and write task waiting for writing to be possible again). That will have to be investigated.

sdroege avatar Mar 12 '20 10:03 sdroege

One thing that might be a problem from our side is that we need to be able to have up to two wakers per read/write operation

True, I forgot about that issue. That makes it quite specific and maybe not so easy to use a general solution. That really is a particular tungstenite quirk...

najamelan avatar Mar 12 '20 13:03 najamelan

Needs someone to investigate in any case :)

sdroege avatar Apr 12 '20 14:04 sdroege

Just wanted to mention that stjepang also released async-compat, but unfortunately it doesnt work for tokio 0.3 and it seems to always load tokio with the rt feature... also might not deal with the double waker issue.

najamelan avatar Nov 02 '20 09:11 najamelan