📝 Get your *FREE Rust cheat sheet* : www.letsgetrusty.com/cheatsheet
@sonicsplasher11 ай бұрын
Just 15 videos to go. You got this
@everyhandletaken3 жыл бұрын
I was expecting that to be more complicated.. nice 👍🏻
@magnoelmagnifico9573 жыл бұрын
me too haha
@jonathanmoore56193 жыл бұрын
That's the next part...
@everyhandletaken3 жыл бұрын
@@jonathanmoore5619 calm before the storm ☺️
@veirt3 жыл бұрын
Ikr, the chapter before (smart pointers) was hell for me who came from high level languages
@everyhandletaken3 жыл бұрын
@@veirt I can relate, most things are hell for me 😂
@yousefh49393 жыл бұрын
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
@exoticcoder53653 жыл бұрын
Very useful & clear on why we need to move ownwership into the closure 👍🏻Thank you
@aloysberger94823 жыл бұрын
Good work mate, thank you for these videos they're very good. Keep up the good work.
@kishanbsh3 жыл бұрын
Eagerly awaiting your video on async await and futures
@herrxerex84843 жыл бұрын
Keep it up , man !!! awesome as always
@ClaudioParraGonzalez3 жыл бұрын
Sweet stuff! Thanks, man!
@----__---3 жыл бұрын
eagerly waiting for listening to the async by you
@aqua34183 жыл бұрын
Don't you mean you're _awaiting_ for him to explain it? **nudge nudge**
@mybdretaemch3409 Жыл бұрын
this is very interesting!! nice explanation!
@MrGreen-kq4ds3 жыл бұрын
great video - thanks! do u plan to cover async rust at some point?
@letsgetrusty3 жыл бұрын
Yes!
@bgdjovan Жыл бұрын
Really useful!
@func0der2 жыл бұрын
Thank you very much for this clear video. I learned so much.
@spongechameleon69402 жыл бұрын
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
@emvdl3 жыл бұрын
Thank you! 👍
@alanaxotla91123 жыл бұрын
This is amazing
@jabuci2 жыл бұрын
Can you make a video about scoped threads? New in 1.63.
@TON-vz3pe2 жыл бұрын
How is race condition and dead lock. prevented in this example?
@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?
@KokahZ7777 ай бұрын
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
@saadabbasi20633 жыл бұрын
Please make a video on using Tokio
@letsgetrusty3 жыл бұрын
I will eventually!
@emilfilipov1692 жыл бұрын
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"
@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
@hobbes50432 жыл бұрын
I thought this video was alright. I wish you did more than just rehash the textbook though. Some different examples would have helped.
@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.