@asyncrs What's the equivalent of libstd's mpsc::Receiver::recv_timeout(x)?
`receiver.timeout(x).next()` something is the closest I got, but the docs on Stream::timeout is not clear if it's per item or if the entire stream becomes invalid.
-
-
1 reply 0 retweets 1 like
-
Replying to @bitshiftmask @faernn and
Today it'd be: use async_std::future::timeout; let item = timeout(dur, receiver.recv()).await?; We're in the process of adding `timeout` as a method on Future though; this should make it a bit easier: let item = receiver.recv().timeout(dur).await?;
1 reply 1 retweet 4 likes -
Replying to @yoshuawuyts @bitshiftmask and
I was thinking about that. But I was afraid dropping the recv() Future could lead to missed/dropped items. But if you say this is safe, I'll go with that
1 reply 0 retweets 1 like -
Replying to @faernn @bitshiftmask and
Because futures are "pull", not "push" it means that when you drop a receiver you simply stop taking items out of the queue. They don't go anywhere, hehe. This means in this case it's perfectly fine to just drop, and let another receiver take over at another time (:
1 reply 0 retweets 2 likes -
Replying to @yoshuawuyts @bitshiftmask and
Awesome. Follow up question. What would be the best way, currently, to do the same as libstd's try_recv then? I assume a timeout with duration zero can be very flaky which one gets to go first?
1 reply 0 retweets 0 likes
try_send is easy, but we probably need to expose try_recv natively. We have it internally here: https://github.com/async-rs/async-std/blob/c4ba11ff9539ab4063ad275174e74df4282184bc/src/sync/channel.rs#L769 …; just need to expose it publicly. If you have a use case for this, opening an issue with a short explanation of why you want it would be much appreciated!
-
-
Replying to @yoshuawuyts @bitshiftmask and
Thanks for all the answers
I submitted this:https://github.com/async-rs/async-std/issues/579 …0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.