What's a food resource for learning about @rustlang async these days?
-
-
-
Invited
@flukejones to my smol repository - there's a lot in the examples directory, like TCP/HTTP/TLS/WebSocket servers and clients. The runtime is also small and documented, so if you're into learning how they work - this is a great resource. :) I'll make the repo public soon.3 replies 1 retweet 13 likes -
That's very kind of you! So when you have a task::spawn containing three .await in it, do those run concurrently? I think the one thing that confused me about await is that it always looked like sync code. Can't tell how it works concurrently.
2 replies 0 retweets 1 like -
Does this help perhaps? // a and b run serially a.await; b.await; // a and b run serially spawn(a).await; spawn(b).await; // a and b run concurrently let ta = spawn(a); let tb = spawn(b); ta.await; tb.await; // a and b run concurrently let t = spawn(a); b.await; t.await;
1 reply 0 retweets 3 likes -
That really does. Is that applicable to an async fn returning a future?
1 reply 0 retweets 0 likes -
async fn is just syntax sugar, so these two fns are equivalent: async fn foo() -> T fn foo() -> impl Future<Output = T>
1 reply 0 retweets 5 likes
When you call foo(), nothing happens except you get a lazy future that is yet to do something. You can then do foo().await to await its result, or do spawn(foo()) to start evaluating it the background. Note that spawn() itself gives you a future and is technically an async fn.
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.