The Talk You've Been Await-ing for

  Рет қаралды 63,358

InfoQ

InfoQ

Күн бұрын

Пікірлер: 61
@pictureus
@pictureus 5 жыл бұрын
Steve Klabnik is truely an amazing teacher. I bought the book while I was half way through it online. Still haven't unpacked the physical copy yet; but wanted to support him :) At the last chapter now!
@sociocritical
@sociocritical 4 жыл бұрын
It's really amazing how all of these young people in the Rust Community really care about getting it out into the world for anyone to understand.
@pictureus
@pictureus 3 жыл бұрын
@Sam Claus There wasn't a donation button anywhere and besides I do want to have the book in my collection without just having it stored digitally. This is probably the only thing I have bought for myself the last couple of years except for a new pair of shoes. And I might want to enjoy it without having to look at a screen whilst reading as well.
@falkelh
@falkelh 2 жыл бұрын
I can't believe he's the guy who wrote the book of rust. What a legend 👏👏👏
@scottlott3794
@scottlott3794 5 жыл бұрын
This talk did an amazing job FINALLY explaining how futures work and how the language implements them. Thank you!
@jonarmani8654
@jonarmani8654 3 жыл бұрын
26:37: "There's a really beautiful underlying unified theory of computation that puts all these things together in a wonderful way that I don't have time to explain." Where do I find *that* talk, though? 🙂
@Blure
@Blure 4 жыл бұрын
Quality content. I started learning Rust one year ago and haven't take a step forward into learning async-await since. I think it's time. Thank you Steve for the talk.
@DominicClifton
@DominicClifton 3 жыл бұрын
Great job at explaining the key aspects. Thanks for taking the time to do it.
@EvanCarrollTheGreat
@EvanCarrollTheGreat 4 жыл бұрын
I feel like if I watch this 5,000 more times, I'll be Gandolf awesome.
@fish1r1
@fish1r1 3 жыл бұрын
20:10 as a node dev, I assumed they would run in sequence (await promise1; await promise2;) Edit: corrected timestamp.
@samlaf92
@samlaf92 2 жыл бұрын
Ya I think he's wrong. node has the same behavior; you need to await Promise.all(promise1, promise2) the same way you do in rust.
2 жыл бұрын
What spawn does is it gives a future to the runtime to be executed concurrently with the current running future (either cooperatively within the current thread, or in a separate thread, depending on how you configure your runtime). Meaning, it puts the future in the ready task of the runtime. The #[tokio::main] and Runtime::block_on will block on a single future. When the future finishes, other ready futures won't execute. To execute them, you need to cooperatively (asyc cond var + async mutex, async channel) block the future and let the other futures notify when you can unblock.
@Dominik-K
@Dominik-K 3 жыл бұрын
Thanks for this talk, this is actually very impressive and I like the overall design philosophy a lot! Normally the overhead is pretty big, but this seems like a nice API design to me
@wrong1029
@wrong1029 5 жыл бұрын
39:40 BRUH
@SrIgort
@SrIgort 3 жыл бұрын
Awesome! Rust really looks very cool
2 жыл бұрын
One of the problems with async traits is that trait functions can't return "impls". So what you can do (and what async-trait does) is to return a boxed pined dyn Future.
@Antonito1Tonito
@Antonito1Tonito 5 жыл бұрын
Amazing talk, as always, thank you Steve!
@Hector-bj3ls
@Hector-bj3ls 4 жыл бұрын
The title should have been "The talk you've been for.await-ing"
@peter9477
@peter9477 2 жыл бұрын
Actually just "The Talk You've Been Await-ing". The "for" is redundant as "to await" means "to wait for".
@Hector-bj3ls
@Hector-bj3ls 2 жыл бұрын
@@peter9477 No, because the keyword attaches to the future being awaited. So it could have been "(The talk you've been).await-ing"
@peter9477
@peter9477 2 жыл бұрын
@@Hector-bj3ls Ah, I didn't realize the dot was intentional in your comment. It appears frequently in typos in KZbin comments when people miss the space bar or when autocorrect fails. (But if it wasn't clear, I was merely correcting the original English grammatical error in redundantly applying "for" to the word "awaiting.)
@imaliazhar
@imaliazhar 4 жыл бұрын
At 37:00, on registering a future, why don't we directly pass the future to the reactor instead of passing it to executor first? It's very rare that a future is resolved as soon as it's registered. The first call to poll() will almost always return Pending.
@SolomonUcko
@SolomonUcko 4 жыл бұрын
Then the reactor would also need to do the stuff involving storing the task, polling it, etc., which is the goal of the executor.
@foobar8894
@foobar8894 4 жыл бұрын
A future that's complete on first poll may actually be very common, depending on what you're doing. For instance there are often error scenarios that can be returned instantly. Or you might be caching results, or have information in memory or remote depending on configuration, etc. And a function that has hundreds of possible execution path of which just on contains an await still needs to be async, so functions higher in the code hierarchy are also generally more likely to execute to completion instantly. But it all depends on the specific program of course...
@lyingcat9022
@lyingcat9022 4 жыл бұрын
39:46 Random Guy: “So, here’s me face 👨🏻‍🦳 👈”
@rossrogers84
@rossrogers84 4 жыл бұрын
Steve, I unreservedly love your puns.
@WorstDeveloper
@WorstDeveloper 4 жыл бұрын
Does future::join() take more than 2 inputs? Like, it's pretty useless otherwise. What would be the equivalent of Promise.All() in JavaScript?
@hailuong9295
@hailuong9295 2 жыл бұрын
Web join is a macro like a function take varargs in other language, so yes you can join as much future as you want
@KirillLykov
@KirillLykov 2 жыл бұрын
And no stateless coroutines in 2022 😞
@alttagil
@alttagil 2 жыл бұрын
41:56 I don't see how task is returning to the queue here if future is still in Pending state. Could someone explain it to me?
@alttagil
@alttagil 2 жыл бұрын
It seems to be stored in waker created in 10 line and will be waiting for wake up call. But how waker is destroyed if task completed immediately?
@joeldpalmer
@joeldpalmer 3 жыл бұрын
Super. Mega. Ultra. Efficient.
@snarkyboojum
@snarkyboojum 4 жыл бұрын
CloudFlare are doing cool stuff.
@andpe161
@andpe161 5 жыл бұрын
17:27 Interesting; C++ is also getting around to separating async call setup and starting execution: kzbin.info/www/bejne/qneQf61qlreKd68 Also, as a non-Rust programmer, the function of "future::join()" is not at all clear for me from the name.
@guibirow
@guibirow 4 жыл бұрын
It is required because every call to .await will execute the logic inside the future and suspend the processing of the rest of the code, futures do nothing unless polled, when it is separate, each future will execute to completion before the next one start. The join will wrap all tasks and act like one future to be polled concurrently.
@FuyangLiu
@FuyangLiu 4 жыл бұрын
So how's the async trait issue now, do we have some sort of solution or ideas for now?
@ekrem_dincel
@ekrem_dincel 4 жыл бұрын
Peoples are still heavily working on implementing the generic associated types feature. But it is not easy to implement, it has way more use cases than just async trait functions.
@qm3ster
@qm3ster 2 жыл бұрын
The dude at 39:41 escaped
@wprayudo
@wprayudo 5 жыл бұрын
it is like fiber cooperative multitasking?
@xnoreq
@xnoreq 4 жыл бұрын
No, it's just asynchronous programming. If you don't know what that means then look it up.
@bytefu
@bytefu 4 жыл бұрын
Cooperative multitasking is just one way of using futures, you can use threads too. For example, you could be processing a bunch of TCP connections in one thread and doing I/O in a separate thread, and polling these two from the third thread. So TCP and I/O would be done in parallel, but multiplexed cooperatively in their own respective threads.
@DDranks
@DDranks 4 жыл бұрын
It's co-operative multitasking, yes, but it's not based on fibers. Fibers have their own stack, but the tasks here don't.
@evans8245
@evans8245 4 жыл бұрын
guys, are futures similar to observables ??
@sociocritical
@sociocritical 4 жыл бұрын
Its rather similar to Promises like he said in the talk.
@KirillKhalitov
@KirillKhalitov 4 жыл бұрын
Observables are more like rust async streams docs.rs/futures/0.3.5/futures/stream/trait.StreamExt.html
@subschallenge-nh4xp
@subschallenge-nh4xp 5 жыл бұрын
I'm just a starting clothing in Raspberry Pi is how can I start learning about today's topic
@subschallenge-nh4xp
@subschallenge-nh4xp 5 жыл бұрын
@@ReedoTV thank you I care. This is a new language and do you develop some application game or whatever will it fit I would usefull to how can it be apply
@first-thoughtgiver-of-will2456
@first-thoughtgiver-of-will2456 4 жыл бұрын
why isnt future::join a macro?
@hailuong9295
@hailuong9295 2 жыл бұрын
It is macro indeed
@RaymondCapozzi
@RaymondCapozzi 4 жыл бұрын
Ruby goto available as a compile option. #define SUPPORT_JOKE 1
@pardal_bs
@pardal_bs 4 жыл бұрын
In JS, if you await two promises that take 5 secs each one after the other, it will take 10 secs. future::join() is equivalent to Promise.all().
@simonthelen5910
@simonthelen5910 4 жыл бұрын
Not quite. I depends on whether you call await before you create the second future or after. So await delay(5); await delay(5); takes 10 seconds, while const a = delay(5); const b = delay(5); await a; await b; only takes 5.
@pardal_bs
@pardal_bs 4 жыл бұрын
@@simonthelen5910 Right, because the promise callback is executed as soon as the promise is created.
@guibirow
@guibirow 4 жыл бұрын
The main argument he tried to make is, in JS the promise is started before you await it, this is why you can call await on them separately and still have them take the same amount of time. In rust, if you don't await the future it won't get started
@CryZe92
@CryZe92 4 жыл бұрын
​@@guibirow Unfortunately Steve didn't fully get it right either. .poll() doesn't get called until .await is called. However in his own timer future the sleep already starts happening as soon as the future and thus the thread is created, which is before ever awaiting it. However the Delay one from the library does indeed only start waiting on the first call to poll.
@weylandyutani4254
@weylandyutani4254 3 жыл бұрын
...that's a pretty bad cough.
2 жыл бұрын
Generators = coroutines.
@MS-ho9wq
@MS-ho9wq 2 жыл бұрын
shouldn't it be the talk you've been awaiting
@itacirgabral1687
@itacirgabral1687 2 жыл бұрын
i_sleep needs Promise.all in js land too
Rust's Journey to Async/Await
48:46
InfoQ
Рет қаралды 87 М.
Is It Time to Rewrite the Operating System in Rust?
1:09:18
InfoQ
Рет қаралды 303 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
"Type-Driven API Design in Rust" by Will Crichton
40:57
Strange Loop Conference
Рет қаралды 126 М.
Netflix Removed React?
20:36
Theo - t3․gg
Рет қаралды 68 М.
A Firehose of Rust, for busy people who know some C++
1:24:12
Jack O'Connor
Рет қаралды 86 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 787 М.
Considering Rust
1:03:57
Jon Gjengset
Рет қаралды 193 М.
7 Outside The Box Puzzles
12:16
MindYourDecisions
Рет қаралды 183 М.
Why Microcontrollers are a good AI companion
20:29
Andreas Spiess
Рет қаралды 10 М.
Crust of Rust: Lifetime Annotations
1:33:23
Jon Gjengset
Рет қаралды 226 М.
Rant: Entity systems and the Rust borrow checker ... or something.
1:01:51
Rust Programming Techniques
1:32:02
LinuxConfAu 2018 - Sydney, Australia
Рет қаралды 96 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН