Тёмный

The What and How of Futures and async/await in Rust 

Jon Gjengset
Подписаться 83 тыс.
Просмотров 97 тыс.
50% 1

Futures are Rust's way of expressing asynchronous computations, but even after reading the documentation, it can be hard to figure out how all the pieces of futures (and tokio) fit together. While this may not matter too much if you're just using futures, it becomes a stumbling block once you want to implement asynchronous primitives yourself. The highly anticipated async and await keywords that are coming down the pike promise to greatly reduce the friction of writing and using asynchronous code, but add even more to the mystery of how this stuff all works.
NOTE: The RU-vid transcoding process seems to have introduce audio lag on all the non-1080p versions. I'll report it to YT, but if it's bothering you, the 1080p version works fine :)
In this stream, we tackle all of this head on. We go through what futures are, how they work, how they are used to represent things like asynchronous I/O (like networking), how they are executed, and how they are evolving as they are being adopted into the standard library. We also discuss async/await, and how they affect futures, and how Rust's proposed pinning types act as the glue to make async/await work.
This is pretty dense material, but hopefully serves as a good and thorough overview of futures in Rust. If you want to know how it all works, this stream probably has you covered! To help you navigate, here are the major transition points:
0:00:00 - Introduction
0:05:57 - What are futures?
0:16:39 - How are futures executed?
0:26:10 - Super weird audio problems
0:29:09 - All good again! (you didn't miss anything)
0:50:04 - How do you integrate futures with I/O?
1:36:11 - Driving futures with Tokio
1:49:28 - Multi-threaded future execution
2:15:00 - Stream and Sink
2:17:11 - (brief aside about tokio-io-pool)
2:24:07 - Putting futures in the standard library
2:30:00 - Arbitrary self types
2:33:46 - What is async/await?
2:46:58 - Why is async/await hard?
2:53:34 - Self-referential data-types
2:58:48 - Pinning!
3:50:40 - Q&A
The tokio documentation push is being organized at github.com/tokio-rs/doc-push.
You can vote for the next stream topic at jon.thesquareplanet.com/live-... !
Live version with chat history here: • The What and How of Fu...

Наука

Опубликовано:

 

30 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 145   
@kiffeeify
@kiffeeify 3 года назад
I must say, even 2 years later, with all the things just stabilized this was super helpful for a newcomer to rust! I just gives the necessary background over some of the rough edges that still seem to shine through in the present.
@tomassedlak3366
@tomassedlak3366 5 лет назад
This video is pure gold! Thank you for doing this.
@kimsnj
@kimsnj 5 лет назад
Great stream! It's really neat to have such a tour of the ecosystem current and upcoming. Thanks! I was surprised by the duration of the video when clicking the (reddit) link. But I did watch it completely as it was really easy to follow along while still being pretty rich!
@deteam
@deteam 5 лет назад
4 hours well spent. Thank you!
@CristianoMartiniBergamo
@CristianoMartiniBergamo 5 лет назад
Congrats. I had many doubts and your explanation helps me a lot! Thank you.
@k.cherukuri643
@k.cherukuri643 5 лет назад
Opened the video and liked it first. After then started watching the video.
@jonhoo
@jonhoo 5 лет назад
I hope you still liked it after watching ^_^
@k.cherukuri643
@k.cherukuri643 5 лет назад
@@jonhoo I always finds something to learn from your videos ever since I watched async-ssh. Keep going and thanks for the quality content !!
@jon36teen
@jon36teen 4 года назад
​@@jonhoo Great Content, thanks for doing this!
@tomasz-waszczyk
@tomasz-waszczyk 3 года назад
Same here.
@michaelhabib1899
@michaelhabib1899 5 лет назад
Awesome video! Excited to have found your channel. Would love to see a video on implementing MQTT.
@jonhoo
@jonhoo 5 лет назад
That's a cool idea! I'll look into adding it to jon.thesquareplanet.com/live-coding/ soon!
@Raniyahmed
@Raniyahmed 3 года назад
One of the most insightful rust channels on utube
@felix111
@felix111 5 лет назад
That’s awesome material, thanks for this 👌
@findsun2005
@findsun2005 4 года назад
Great introduction of async programming in Rust. As the async/await got stabilized in recent rust releases, could you re-illustrate the concepts to us again? Thanks!
@csebastian3
@csebastian3 3 года назад
Yes! Despite this video's age, it is still the best overview of Rust async I have seen. It would be *great* to get an update. Much has happened in the past 2 years!
@xnoreq
@xnoreq 3 года назад
I cannot it.await
@mzr4141
@mzr4141 2 года назад
+1 an update would be great!
@lauritzt
@lauritzt 2 года назад
There is a newer video about this here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ThjvMReOXYM.html
@Tirka100
@Tirka100 4 года назад
Great channel, Jon! Lot of useful stuff! Rust is awesome!
@MatthewFerrin
@MatthewFerrin 5 лет назад
I was surprised to find the video is 4 hours long.
@dntwantgglplus
@dntwantgglplus 4 года назад
in rust, things that are trivial in other languages require a phd and 2 years of your life
@MatthewFerrin
@MatthewFerrin 4 года назад
@@dntwantgglplus, I have not found this to be true personally. I feel that C and C++ are more difficult languages. I do feel like lifetimes should be more automatic though, allowing function parameters to take ownership and function returns to give that ownership right back. I don't know how to survive without structs right now, and that seems unnecessary.
@LongFacedBastard
@LongFacedBastard 9 месяцев назад
​@@dntwantgglplusthis is only true in the case where other languages have obscured tasks which require education to understand
@xenon5993
@xenon5993 3 года назад
"There's an echo...? Uh, the drugs just kicked in!" xD
@SimGunther
@SimGunther 3 года назад
26:09 XD
@Roms8313
@Roms8313 3 года назад
that's psychedelic AF XD but super interesting as ever !
@morganmoskalyk5758
@morganmoskalyk5758 4 года назад
great video, even better typing / keyboard. much enjoyed the back and forth between coding and drawing.
@OMGSoothsayer95
@OMGSoothsayer95 3 года назад
Thanks Jon, this video is really helpful
@junjiewu6165
@junjiewu6165 Год назад
Awesome video! Thanks for doing this😊
@govardhangd9387
@govardhangd9387 5 лет назад
definitely need more such videos
@pseudo_goose
@pseudo_goose 5 лет назад
Thanks for explaining thread pools and work stealing. I've always thought about it conceptually as if there is a single shared queue of jobs that each thread can take from collectively, like what you might see if multiple consumers read from a single queue in message queuing servers like AMQP or MQTT. You could do the same in a thread pool, but each thread will have to hold an Arc and lock it 1-2 times for each future, which could degrade performance as it tries to scale to many more concurrent threads. This could theoretically happen in work stealing too, where most workers get cheap tasks that finish quickly, but some get expensive tasks that might even fork a lot and create a large queue locally. Then, as the cheaper tasks finish, they all start to help out on the few queues that are left. Is that really a problem in practice, or does the random distribution of futures from the runtime typically avoid that scenario?
@karelhrkal8753
@karelhrkal8753 Год назад
The most confusing thing about pin for me was: why is it Pin and not Box? The first one looks like you cannot move the box, which would be silly. But as you explained, Pin doesn't mean T is immovable, it means that T::Target is immovable (where T: Deref).
@TheInspctrcat
@TheInspctrcat 9 месяцев назад
You are really good teacher, big thanks 🙏
@karelhrkal8753
@karelhrkal8753 Год назад
So basically the OS does all the work of waking up tasks when they are ready and everything is "just" a wrapper around epoll, which kind of woks like Promise.race(), excepts it blocks until at least one of the tasks is ready.
@viktorwestberg2290
@viktorwestberg2290 3 года назад
Thank you so much for this!
@toddfulton2280
@toddfulton2280 3 года назад
Thank you. Probably the most in-depth discussion on how async code in rust works I've come across. Read a couple books and neither actually explain much about these topics. One question though. I understand that rust doesn't have overloaded functions, or "constructors" (in the c++ sense) due to design choices. I read in one of the rust topics that overloaded resolution would be too "arbitrary", basically they didn't want to deal with it and function overloading isn't needed. Fair enough. One thing I kept thinking about in the discussion about Pinning, "wouldn't a custom move constructor solve the issue that pinning is trying to solve?" That is, if we have a reference to another member in the same struct, then in the move constructor, you could just reset the reference to self.whatever . Would you say that certain design choices lead to further difficulties down the road? I think this is a good example, because as far as I can tell, overloaded constructors, one with move semantics, would've made the need for pinning in coroutines (? not sure if that's the right term for async functions in rust) a non-issue. I'm sure there are other technical details I'm not aware of here, for example, I'm not sure how moving of c++20's coroutines works, if at all, I'm not an expert in either language, probably just "know enough to be dangerous", so to speak.
@jonhoo
@jonhoo 3 года назад
I think it's for a couple of reasons. First, having a move constructor gets pretty complicated, because now the compiler has to inject calls to that constructor whenever a value is moved, which can potentially be in a lot of places, most of which are pretty irrelevant. The other answer is that having a move constructor probably leads to _more_ complex interactions, not less. The current Pin solution, while tricky to wrap your head around, is highly tailored to what it has to do, and does not introduce _lots_ of additional behaviors that the compiler needs to reason about, nor does it really change the language at all (remember that Pin was initially just a library!). The original RFC also has some discussion you may find interesting: rust-lang.github.io/rfcs/2349-pin.html#comparison-to-move
@toddfulton2280
@toddfulton2280 3 года назад
@@jonhoo Right on. Yeah Pin is great, there are definitely use cases where one needs to explicitly require no moves or they simply aren't necessary, futures for example. In c++ this is usually done by deleting the move/copy constructors respectively. Afaik, Rust already has a default move constructor, probably just memcpy +. Anyways, customizing the move "constructor" or function solves the issue of having to reset self references. It doesn't need to be a "constructor" it could be a trait, if there isn't one already (like Copy?, lots to learn), and an annotation on a member that references another member in the same struct could be used to automatically derive the proper move procedure as far as self referencing structs are concerned. Regarding specialization, I think overloaded functions could also be very useful in there, which is basically what overloaded functions are for. Granted, some other more explicit means/syntax for the user to specify specialized functions could alleviate the compiler of complicated overload resolution especially with regards to generic types (I'm thinking of C++ template specialization and how that affects overload resolution there). Anyways, I think Rust is a great a language and I'm excited to see how it evolves. Thanks again for your great streams! They've taken miles farther in learning Rust than any other source :)
@jonhoo
@jonhoo 3 года назад
Glad to hear it! I mean, you do have limited overloading by virtue of the various traits that different operators use, like Add for +, AddAssign for +=, etc. But you may be thinking of use-cases that are not met by just implementing those traits?
@toddfulton2280
@toddfulton2280 3 года назад
@@jonhoo Well function overloading and having decent overload resolution with generics would essentially solve the specialization issue that they are working on in nightly. That's at least how template specialization works in C++, you define a generic function, and then a specialized version for whatever types you need to treat differently, and then the overload resolution takes care of calling the appropriate implementation at compile time for whatever types you're using at the callsite. Anyways, it's not a major issue at all, the main reason I chose to learn rust and start a project with it over C++, isn't because of the static analysis built into the compiler (though that is certainly a nice feature), it was Cargo and the couple years of maturity that async/await Rust has over C++. This thread highlights pretty well what I think I'm trying to say: internals.rust-lang.org/t/idea-limited-custom-move-semantics-through-explicitly-specified-relocations/6704/16 The choice to not implement certain features because they would be "too complex for people and they would abuse them and the world would end" rubs me the wrong way and am pretty sure such arguments are a sort of fallacy that distract from why some features are actually useful. I'm used the footgun of C++, and the power that it gives me as a developer. There's this sort of movement, not related to Rust directly, trying to push software development/programming onto the masses ("Everyone should code"), which I disagree with. Programming is an engineering discipline, it's not flipping burgers, and I think Rust sometimes treats us like McDonalds employees. The "safety" of Rust is one thing I like (read built-in static analysis and philosophy), but on the other-hand, in certain cases it does become an issue. One thing that concerns me about any community is how dogmatic it is. For example, when learning to code in a functional style for X imperative language, one shouldn't be too dogmatic about being functional as it can lead to poor performance or totally unreadable code. I think in Rust the issue, "we're not going to implement that feature for XYZ reasons due to our philosophy" which ends up leading to other feature being much more difficult to solve, or essentially just reinventing the wheel with a different syntax and name. That's all. That said, I still really like Rust in general, it has a really nice blend of imperative and functional style, it's like if C and Haskell had a baby and ... ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-tTf-nHFnntE.html
@aleksandrkravtsov8727
@aleksandrkravtsov8727 4 года назад
Hi Jon, I think it would be grate if you can write some C code using epoll/poll/select, and then how one can implement the same using Rust's mio library. I don't know what is the format of your streams and do you write real code, but anyway thank you for those explanations, it's really helpful
@junyuzhan6555
@junyuzhan6555 5 лет назад
Thanks for this.
@bloggervista
@bloggervista 5 лет назад
thanks for info.
@simplthink
@simplthink 8 месяцев назад
@jonhoo, nice video , thank you. I had a question on “Every future must arrange for its task to be notified.” The Notifier seems like specialised logic which can’t be pre-determined( because user decides the value the future type resolves to. ) Couple of notifiers examples could be : Notifier for TCP connection completion, Notifier for packet arrival etc. ) But how does async know all kinds of Notifiers ahead of time to code into the compiler ?
@csebastian3
@csebastian3 3 года назад
This was a GREAT overview. Please give us an update when you can.
@CitizensCommunity
@CitizensCommunity 9 месяцев назад
Typing code that is not what we are supposed to use is so frustrating, it is not like it is easy to choose what to remember when one is just trying to figure out what is right to begin with. Otherwise this was super helpful, thank you.
@zonico5826
@zonico5826 5 лет назад
This is impressive
@romeil691
@romeil691 11 дней назад
Thanks a lot!
@dominicdannies7482
@dominicdannies7482 4 года назад
which keyboard are you using ? Sounds very nice :)
@nosh3019
@nosh3019 4 месяца назад
Super Thanks!
@bqwood
@bqwood 4 года назад
This is great! BTW, what drawing software are you using? And is there a stylus involved somewhere?
@jonhoo
@jonhoo 4 года назад
Thanks! I'm using MyPaint on Linux with a Huion Inspiron 640P. I think pretty much any tablet will do for this sort of sketching though.
@renegade5942
@renegade5942 Год назад
we need an updated version of this
@najeebullahshah3446
@najeebullahshah3446 3 года назад
You are amazing
@KnThSelf2ThSelfBTrue
@KnThSelf2ThSelfBTrue 5 лет назад
Thanks Jon! I hope I can pay this gift forward one day, because you know I can't pay the knowledge back!
@lyshenshing9601
@lyshenshing9601 5 лет назад
Can you make new livestream about Mio in Rust programming and explains most of function in it(any technique word)?
@samjudelson
@samjudelson 3 года назад
This was so good I'm going to !Unpin it in my brain.
@mybigbeak
@mybigbeak 5 лет назад
Thanks so much for this video it's cleared up soo many things and might just save my life. you say in the workstealing section (2:07:00) ish that you have to take other parts across or return the future back to it's old queue. Surely you are only taking the Ready futures. So when they block they can notnfy the current thread?
@jonhoo
@jonhoo 5 лет назад
Glad you found it helpful! I'm not entirely sure I understand your question; it's not a problem to executee a future on a different worker, all that matters when work stealing is that the notifications are still issued from the original worker. To avoid cross-thread communication, we may therefore want to return a NotReady future to the queue of its origin worker.
@mybigbeak
@mybigbeak 5 лет назад
@@jonhoo thanks for the reply, I'll try to clarify. Why can't you just keep it on the stealing thread as is? It's been stolen in a ready state, so it has nothing it's waiting for? So if it does become unready can't it just notify the waker on the new thread. I'm sure there is a reason, but I can't quite catch it.
@jonhoo
@jonhoo 5 лет назад
Ah, you _can_ keep it on the same thread, but having one thread notify another thread is much more expensive than notifying yourself. If we keep a stolen future on the other worker, then we'll have to keep doing cross-thread notifications, whereas if we return it we no longer have to!
@Italya3343
@Italya3343 3 года назад
Thank for your hard work and for sharing that amazing video, bro!! 👏 👏 👏 I've a question, can we say that Rust/Tokio is like Node.js?!?! Thx
@jonhoo
@jonhoo 3 года назад
Well, kind of. But the analogy isn't perfect (beyond the fact that the languages are quite different). One of the biggest differences is that with tokio you get multithreaded execution, which Node.js doesn't generally give you :)
@Italya3343
@Italya3343 3 года назад
Many thanks for your response, bro!! 👏👏👏 So all we need now an equivalent for Express.js and to be able to use React.js 🤩🤲
@alexandrugutan7587
@alexandrugutan7587 5 лет назад
Gold
@erwinditer450
@erwinditer450 2 года назад
that random python question in the middle of the stream got me
@thalyssonleite1479
@thalyssonleite1479 9 месяцев назад
A Masterclass
@risboo6909
@risboo6909 4 года назад
Great video, thanks. I'm wondering whether tokio work stealing is able to steal jobs with descriptors from other threads epolls in 2020?
@jonhoo
@jonhoo 4 года назад
These days, tokio has a single "floating" reactor that whichever worker thread is idle is responsible for turning. It can move from one thread to another as load changes. I believe there are plans to allow multiple reactors, but to my knowledge it has not been implemented (or been needed) so far.
@qm3ster
@qm3ster 5 лет назад
In `CompilerMadeAsyncBlock` enum, will things like `z` that aren't used any more after a particular `await!` still be stored, or will they drop?
@jonhoo
@jonhoo 5 лет назад
I'm actually not entirely sure how the real `await!` interacts with dropping local variables. My guess would be that they're dropped according to normal scoping rules, though I'm not sure how the compiler enforces that. Keep in mind that the `enum` I give isn't _actually_ what the compiler uses, it's just a handy way to think about it :)
@grog8164
@grog8164 5 лет назад
Thaaaaaaanks you sir
@user-to3oi7ve8t
@user-to3oi7ve8t 4 года назад
what's the relation between the async/.await and tokio (executor) ? i'm a rookie ,would you like to recomend some articles or blogs
@jasonish
@jasonish 5 лет назад
I do not believe tokio-codec is going anywhere. Do you have a reference? Thanks.
@jonhoo
@jonhoo 5 лет назад
I said this around 2:14:44, and you're totally right, tokio-codec is not going away. I somehow got it in my head that it was not going to be included with tokio, but that's not the case. tokio-codec is alive and well :p
@aiomixrecords
@aiomixrecords 4 года назад
Thank you so much Jon! What if a task_a in thread_a is waiting on a lot of Tcp responses from diff threads(b,c), could task_a handles its current notifyhandler to both threads(b,c) that will randomly notify the task_a in thread_a and it might get notified simultaneously at the same time, do you think this is possible? btw am in love in your hardwork as a developer moving from Erlang/Elixir world(actor model) to futures world.
@aiomixrecords
@aiomixrecords 4 года назад
I think implementing an atomic operations (fetch_add, fetch_sub) might work, imagine the task was_notifed state is not bool instead is an integer, where the threads(b,c) do fetch_add while thread_a do fetch_sub. so the executor will just check the was_notifed integer state, you think this kind of operation is inexpensive?
@jonhoo
@jonhoo 4 года назад
I'm not entirely sure what the question is? Are you concerned about correctness or performance here? Wakeups are already implemented using atomics :)
@aiomixrecords
@aiomixrecords 4 года назад
hey @@jonhoo, am concerned more about the correctness first and then the performance as well, after giving it a lot of thoughts, I guess having a notification channel is might be better than fetch_add,fetch_sub, because the channel will only consume O(n) where n is the tasks that are ready to do progress(have notification), while managing an atomic integer state will force executor to loop through all executor_map(which hold all the tasks) and then check if it was_notified flag(have integer atomic state greater than 0), what do you think? am new to the rust world, and without you I might never understood the overall picture, so all the credits to you, as am currently implementing(actually still designing) a shared nothing architecture I hope if you could advice whether is good to go with epoll or io_submit/io_getevents(batching), or mostly io_uring(am still wondering how to do that in futures world) and maybe emulating epoll with IORING_OP_POLL_ADD/REMOVE, don't you think this might be better than blocking on epoll?
@aiomixrecords
@aiomixrecords 4 года назад
sorry back again to the question, "Wakeups are already implemented using atomics", consider the task is an actor, this actor receive events from its channel, therefore it should only be awaken once per event, and thats why I went with shared nothing architecture model, otherwise I might go with work stealing pool if I can ensure that no two/x threads will awake the actor at the same time! :) Thank you again for your quick response, please take the time.
@jonhoo
@jonhoo 4 года назад
Ah, sorry, to be clear, what I present in the video is an _extremely_ simplified view of what the tokio runtime actually does to schedule tasks and wakeups. In practice, a _lot_ of optimization and testing has gone into making it both correct and very fast, and that includes several fancy lock-free datastructures, clever use of atomics and thread-locals, as well as lots of algorithmic work on scheduling and such. The current tokio runtime actually looks a lot like the runtime that Go uses for its goroutines. If you want to know more about how the runtime _actually_ works, I would recommend you head over to gitter.im/tokio-rs/tokio where the tokio developers hang out, or just dive into the code yourself! They (Carl in particular) can probably also give you better answers than I can about what kind of syscall interface would work best for your intended use-case.
@gloatsticks
@gloatsticks 3 года назад
Hey I may have missed you answering this in the video, do you stream on twitch or youtube?
@jonhoo
@jonhoo 3 года назад
I stream on both. My Twitch channel is www.twitch.tv/jonhoo.
@gloatsticks
@gloatsticks 3 года назад
@@jonhoo awesome thank you!
@chengliu5323
@chengliu5323 4 года назад
Thank you very much for this kind of sharing. I am a front-end engineer, and i think i got a better understanding about function generator in node.js world as well :)
@AmitKumar-zk9pq
@AmitKumar-zk9pq 4 года назад
@Jon, where can I read more about async sys calls.
@JayButera
@JayButera 5 лет назад
What browser/plugins are you using to get that nice dark theme?
@jonhoo
@jonhoo 5 лет назад
Oh, that's just the default Firefox Developer edition theme. I think there are ways to enable the dark theme on non-Developer editions too with some fiddling with the settings if you Google it!
@qm3ster
@qm3ster 5 лет назад
@@jonhoo What about putting the url bar/etc at the bottom?
@MauriSN870
@MauriSN870 5 лет назад
You could use something like screenkey to show what keys are being pressed in your keyboard, that would be awesome!
@jonhoo
@jonhoo 5 лет назад
Hmm, that's an interesting idea. What makes you think that'd be useful? Most of the relevant text is visible in vim anyway?
@MauriSN870
@MauriSN870 5 лет назад
Yes, most of the text os visible, but not your keybindings. Would be cool to see what shortcuts you are pressing.
@jonhoo
@jonhoo 5 лет назад
True, but I think that'd lose novelty value very quickly, as I'm not using anything _super_ fancy most of the time. The code is the focus, not the editor. I might do it for a shorter stream though, that's a good idea!
@MauriSN870
@MauriSN870 5 лет назад
Ty for your attention Jon :)
@jacklong2182
@jacklong2182 3 года назад
Are you live coding to implement the rust std modules ?
@Abdullahkhan-ks2py
@Abdullahkhan-ks2py 3 года назад
Which editor is that in the thumbnail!?
@kiffeeify
@kiffeeify 3 года назад
Hey folks, @1:24:25 As I understand, the whole `with_default` is now replaced by the `waker` functionality in the stabilized API!?
@markozagar
@markozagar 4 года назад
At 3:23:20, will the compiler still add the 'Unpin' marker to 'Bar', since a member of bar does not have this marker, or am I missing something about auto traits?
@jonhoo
@jonhoo 4 года назад
I'm not sure I follow the question - a type only gets an auto trait if all of its members implement the auto trait. If any member does not, the parent type also does not.
@markozagar
@markozagar 4 года назад
@@jonhoo That was my understanding. Therefore, because `Bar` included `Foo` as a member, and we specifically opted out of `Unpin` on `Foo`, that should mean that `Bar` is also `!Unpin`, and thus not allowed to be moved.
@jonhoo
@jonhoo 4 года назад
Yup, that is correct. When you then use `Box::pin` (which gives you a `Pin`), it prevents you from moving the `Bar`. However, you _are_ allowed and able to move the `Foo` _inside_ `Bar`, since the `Foo` is _not_ behind a `Pin`. Or, in other words, the `Pin` only applies one "level" deep.
@markozagar
@markozagar 4 года назад
@@jonhoo Oooh, that was the missing link! Thanks! Amazing video, btw! I'm always interested in learning the internals of stuff like this.
@qm3ster
@qm3ster 5 лет назад
RE: Audio - Do you have a USB microphone + a motherboard audio microphone both listening? The weird issue seems like USB dropped some packets and then reconnected, so you would need to add latency to the faster one to continue with both.
@jonhoo
@jonhoo 5 лет назад
Nope, just the USB microphone, so not entirely sure what happened there. Hasn't happened since either :shrug:
@chrisabruce
@chrisabruce 5 лет назад
How did you get the base16 theme for docs.rs website?
@jonhoo
@jonhoo 5 лет назад
Oh, that's not base16. That's just the docs.rs dark theme. Click the little gear near the top left and choose "dark".
@ShyamBaskaranphi
@ShyamBaskaranphi 5 лет назад
Hey, which OS are you using?
@jonhoo
@jonhoo 5 лет назад
This is Arch Linux. See also my walk through of my setup here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ycMiMDHopNc.html
@elahn_i
@elahn_i 5 лет назад
Thank you, I now understand why it's called Unpin.
@adinesh7989
@adinesh7989 5 лет назад
smooth af.
@gangwang2547
@gangwang2547 5 лет назад
how do you set your vim?
@jonhoo
@jonhoo 5 лет назад
Hi Gang! I go through all of that in this video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ycMiMDHopNc.html
@bilbobeutlin6979
@bilbobeutlin6979 5 лет назад
Is this still relevant with futures 0.3 and now/very soon being in stable?
@jonhoo
@jonhoo 5 лет назад
Yup, all of this still applies to futures being in the standard library! The design of futures themselves hasn't really changed.
@bilbobeutlin6979
@bilbobeutlin6979 5 лет назад
@@jonhoo Thanks. This video really is unbeatable!
@samuelsa8036
@samuelsa8036 5 лет назад
Oh i love this,i like Rust。Thanks for sharing.But the time is tooooooo long..... ^ ^
@anibalfernandoantonelli3524
@anibalfernandoantonelli3524 4 года назад
I thought this video was 4 minutes 10 seconds long. "Something to watch and learn quickly."
@renegade5942
@renegade5942 Год назад
dude is crazy when typing, i thought the primeagen was fast
@well.8395
@well.8395 11 месяцев назад
You should search for "Neal Wu" dude literally does 156wpm while typing code.
@mariusnunnerich5027
@mariusnunnerich5027 5 лет назад
The link to the poll is broken.
@jonhoo
@jonhoo 5 лет назад
Should be fixed now!
@pegleg2060
@pegleg2060 4 года назад
Bro, please gift me your vim skills. You make me feel like an absolute noob. Is that i3 on arch? When you quickly switched between terminal/vim file1/vim file2 how were you doing that? Was it in the terminal and switching between tabs, or a shortcut within vim?
@jonhoo
@jonhoo 4 года назад
It's xmonad actually, but any tiling window manager works just as well! I have a shortcut in vim for switching quickly back and forth between the two most recently-used buffers. See github.com/jonhoo/configs/blob/b6d4aee616d234f581766b467a0e772e775cc53f/editor/.config/nvim/init.vim#L372. In stock vim you can do so using C-^.
@akarshjain7141
@akarshjain7141 2 года назад
Echo!! bit flip maybe ?
@makichkaragezyan9512
@makichkaragezyan9512 4 года назад
27:10 psychedelic))
@yangxu1086
@yangxu1086 5 лет назад
Can I find the source code somewhere?
@jonhoo
@jonhoo 5 лет назад
The source code of what?
@xXRauLXx2010
@xXRauLXx2010 2 года назад
Oh, how the 10 year old Romanian boy in me rejoices at seeing the word "fut".
@xplinux22
@xplinux22 5 лет назад
Your first example of an async function uses incorrect syntax. First, it's _async fn_ and not _fn async._ Second, it wouldn't return an _impl Future,_ it would simply return _T_ like so: *async fn foobar() -> T { ... }*
@jonhoo
@jonhoo 5 лет назад
The exact syntax isn't terribly important I think -- this video is more trying to teach you how futures and async/await works under the hood, and then showing that it does in fact return a Future is more important (I'd argue) than being technically correct to the syntax. As for the order of async and fn, I don't think that's terribly important when it comes to conveying understanding of the underlying concepts, but you're totally right! That is something the compiler would tell you pretty quickly if you started writing async code though :)
@xplinux22
@xplinux22 5 лет назад
@@jonhoo That's a fair point, yeah! Rereading my original content, I'm sorry if I came across too dismissive. It's currently 6AM, and I haven't gone to sleep yet. I do think you did a good job of getting the main point across, and in fact, I would like to at least thank you for the excellent stream. I am just a little worried that it could be a little confusing to show _impl Trait_ being mixed with the _async_ function signature like that when _async_ itself is implemented in terms of _impl Trait._ But you're right, it's not that big of a deal. Still love the video!
@jonhoo
@jonhoo 5 лет назад
Hehe, no worries, comments online are notoriously bad at conveying tone and context, so I just assumed you were coming from a good place :) I'm glad you enjoyed it and found it helpful! You are totally right that it's not technically accurate, and I agree that's unfortunate, but at the same time: a) an async function really does return something akin to impl Future, that's just not what you _type_, so for the purposes of exposition, that's probably a better way to show what's going on "under the hood"; b) if someone were to try to write async fn -> impl Future, the compiler would correct them very quickly, and they would realize that the extra impl Future bit isn't necessary; c) the return type of async fn actually _was_ written impl Future for a while, and then it was changed to avoid the extra boilerplate; and finally d) I can't actually change the video at this point, so sadly I don't have a good way to resolve this after the fact. I suppose I could mention it in the video description, but I suspect very few people actually read that anyway :p
@endianAphones
@endianAphones 3 года назад
Great video, but you didn't have to use a typewriter.
@drozdziak1
@drozdziak1 5 лет назад
I find you audio very quiet! I'd much prefer not to lose my hearing to facebook notifs. I turned up the volume to the max on this firefox tab but it's not enough
@jonhoo
@jonhoo 5 лет назад
That's interesting, you're right, it does seem pretty quiet, but I'm not sure why. I think my microphone is turned all the way up, but something is clearly wrong. I'll make sure to look into it for the next stream!
@krtirtho
@krtirtho 3 года назад
I thinks you can efficiently reduce the time of the tutorials as 4hrs is too much. Also some of the talking, loading time etc.. can be cut out from the main video
@jonhoo
@jonhoo 3 года назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-KPbrI3xWdCg.html :)
@qm3ster
@qm3ster 5 лет назад
// T notices that a network packet arrived println("OwO what's this?!");
@plmwd
@plmwd 3 года назад
I am so lost
@Dygear
@Dygear Год назад
*Makes squiggly lines* You can tell this is code because *Puts a curly bracket by the squiggly lines* because there is a curly bracket. LMAO
Далее
Crust of Rust: Send, Sync, and their implementors
1:07:04
The Why, What, and How of Pinning in Rust
3:03:54
Просмотров 68 тыс.
HUMAN BASKETBALL! 👀🏀🤣 | Triple Charm #Shorts
00:15
Crust of Rust: Declarative Macros
1:36:11
Просмотров 63 тыс.
Considering Rust
1:03:57
Просмотров 189 тыс.
1 Hour Dive into Asynchronous Rust
1:14:12
Просмотров 17 тыс.
Crust of Rust: async/await
2:34:01
Просмотров 182 тыс.
Implementing (part of) a BitTorrent client in Rust
4:09:16
Intro to async/.await in Rust
13:57
Просмотров 83 тыс.
Что не так с Sharp? #sharp
0:55
Просмотров 117 тыс.
Телефон в воде 🤯
0:28
Просмотров 1,2 млн