📝 Get your *FREE Rust cheat sheet* : www.letsgetrusty.com/cheatsheet
@everyhandletaken
3 жыл бұрын
I was expecting that to be more complicated.. nice 👍🏻
@magnoelmagnifico957
3 жыл бұрын
me too haha
@jonathanmoore5619
3 жыл бұрын
That's the next part...
@everyhandletaken
3 жыл бұрын
@@jonathanmoore5619 calm before the storm ☺️
@veirt
3 жыл бұрын
Ikr, the chapter before (smart pointers) was hell for me who came from high level languages
@everyhandletaken
3 жыл бұрын
@@veirt I can relate, most things are hell for me 😂
@spongechameleon6940
2 жыл бұрын
Is there an idiomatic way to pass the same data in heap to multiple threads for reads? Like by wrapping the data in Rc?
@cat-.-
Жыл бұрын
std::sync::Arc
@mdrealiyev
Жыл бұрын
Hello. Evertig is good and understandable. But I have a question. How can I call thread::spawn inside implemented class and pass self safety?
@KokahZ777
3 ай бұрын
I pattern I found is to wrap your struct (call it A) data in some Inner struct that is Arc in A That way you can pass a self clone to your functions which just duplicates the pointer but not the actual data
@sonicsplasher
7 ай бұрын
Just 15 videos to go. You got this
@MrGreen-kq4ds
3 жыл бұрын
great video - thanks! do u plan to cover async rust at some point?
@letsgetrusty
3 жыл бұрын
Yes!
@exoticcoder5365
2 жыл бұрын
Very useful & clear on why we need to move ownwership into the closure 👍🏻Thank you
@aloysberger9482
2 жыл бұрын
Good work mate, thank you for these videos they're very good. Keep up the good work.
@emilfilipov169
Жыл бұрын
I find this confusing and I can't find anyone who has explained it yet. So, the thread takes ownership of your variable, say v, for example. You "can't" use it outside of the thread, but yet you can. fn main() { let limit: i32 = 5; let handle = thread::spawn(move || { for n in 1..=limit { println!("Spawned, {}", n * n); thread::sleep(Duration::from_millis(1)) } }); for n in 1..=limit { println!("Main, {}", n * n); thread::sleep(Duration::from_millis(1)) } handle.join().unwrap(); } Why does this code run? If one thread has ownership of the variable, doesn't that mean nothing else can own it?
@kylezwarich
Жыл бұрын
The move keyword for closure tells Rust compiler to keep "limit" in scope for the duration of the spawned thread, and handle.join().unwrap() says to run all threads through to completion. So every loop iteration the spawned thread asks "is limit still a thing", Rust says "it is a thing because you still need it"; even though the main thread might have finished processing its batch of loops already, the other still needs access to 'limit'. If me and you order spaghetti and meatballs, but I hate noodles and you hate meatballs, we can split the dish and we both have a satisfying meal, but we have to share the fork. Just because I'm finished all the meatballs doesn't necessarily mean our dinner is done--using the move keyword and the thread::join() says "we both need the fork so don't get rid of it until we're both done the plate"
@saadabbasi2063
3 жыл бұрын
Please make a video on using Tokio
@letsgetrusty
3 жыл бұрын
I will eventually!
@kishanbsh
3 жыл бұрын
Eagerly awaiting your video on async await and futures
@yousefh4939
3 жыл бұрын
i will rewatch all the videos after it get complete it make me happy to see you made new video every time i log in youtube
@herrxerex8484
3 жыл бұрын
Keep it up , man !!! awesome as always
@jabuci
2 жыл бұрын
Can you make a video about scoped threads? New in 1.63.
@----__---
3 жыл бұрын
eagerly waiting for listening to the async by you
@aqua3418
3 жыл бұрын
Don't you mean you're _awaiting_ for him to explain it? **nudge nudge**
@janedoe6182
Жыл бұрын
"As soon as you type new Thread(), it’s over; your project already has legacy code" (c) Stephen Cleary In general creating new OS threads in modern programs - bad idea. Except specialized pools serving async I/O
@ClaudioParraGonzalez
3 жыл бұрын
Sweet stuff! Thanks, man!
@alexisgavidia3141
Жыл бұрын
hi, i have a question if !l.iter().any(|x| x.file_name == j.file_name) { //copy file to tmp folder. let y = j.clone(); let ha = thread::spawn(move || async move { cp_to_tmp_and_pod( cmd_start_raw_capture_ecs, y, i, pods, n, &path_on_the_host, ) .await; }); n += 1; l.push(j); ha.join().unwrap().await; } } ha.join().unwrap().await; i cant run it the function wiout the await. and i want to run but the main thred need to wait until this fisnih.
@hobbes5043
2 жыл бұрын
I thought this video was alright. I wish you did more than just rehash the textbook though. Some different examples would have helped.
@TON-vz3pe
Жыл бұрын
How is race condition and dead lock. prevented in this example?
@alanaxotla9112
3 жыл бұрын
This is amazing
@mybdretaemch3409
8 ай бұрын
this is very interesting!! nice explanation!
@emvdl
3 жыл бұрын
Thank you! 👍
@func0der
2 жыл бұрын
Thank you very much for this clear video. I learned so much.
Пікірлер: 36