Concurrency in Rust - Message Passing
Ғылым және технология
The ultimate Rust lang tutorial. Follow along as we go through the Rust lang book chapter by chapter.
📝 Get notified when the Rust Cheatsheet comes out: letsgetrusty.com/cheatsheet
The Rust book: doc.rust-lang.org/stable/book/
Chapters:
0:00 Intro
0:38 Transfer Data Between Threads
5:54 Channels and Ownership Transference
6:43 Sending Multiple Values
7:46 Creating Multiple Producers
8:56 Outro
#letsgetrusty #rustlang #tutorial
Пікірлер: 35
📝 Get your *FREE Rust cheat sheet* : www.letsgetrusty.com/cheatsheet
I attribute my Rust knowledge to you my man, good work
I have wasted my entire sunday trying to figure out a solution to a problem. I started in the morning, and just now, at 1 am, I found your video which describes the perfect solution to my problem. Thank you so much!!
Thanks so much for this series. It's compliments the book well.
Great tutorial! Thank you so much
was waiting for this :]
Totally dig the rubber ducky analogy!
Simple is better than complex, your explanation makes complex to simple. Keep it going Bogdan, let's get rusty :)
@aragonnetje
2 жыл бұрын
Hey now, this isn't python XD
So good, concurrently in rust is so powerful but allot to learn.
this is surprisingly simple
"luckily for us, we get a compile time error!" 😆ik what you mean but it's funny out of context
Excellent! don't you plan to demonstrate how to use message passing among several green threads(fibers) in Rust? It would be awesome! P.S. Спасибо :)
Nice explaination of channels
What is the use case of the message passing? Can you show the examples?
Is there a way to pass messages between modules?
Do you have a video about rust async?
why doesn't rx get moved into the thread as well when we call thread::spawn(move...) ? and how could thread receive messages then
Any good tips for a single producer, multi consumer architecture? I've got a stream I'd like multiple subscribers in different threads to be able to read from.
@DjHeely
2 жыл бұрын
See the tokio broadcast module
@cvspvr
Жыл бұрын
use the flume crate for a mpmc channel
What if I want single producer and multiple receiver? Is a way that only one "free" receriver gets signal? I like to have an architecture like boss and workers.
Will you be covering async await ?
@letsgetrusty
2 жыл бұрын
In the future yes! no pun intended
@eduardrivas6964
2 жыл бұрын
@@letsgetrusty LOL
I'm confused about how clone() works in this context. What happens to the channel when the spawned threads processing, that owns the original tx, is completed? How does the receiver know that there is a cloned sender still out there and that the channel should stay open?
@clubpenguinfan1928
3 ай бұрын
my naive guess is that each transmitter holds a reference to some internal part of the channel/receiver (e.g. to some message queue), so that it gets reference-counted behind the scenes. but yeah, honestly not sure if mspc channels are very fundamentally different from something like, say, an actual message queue behind an Arc
Is this similar to golang channel?
At 7:30 is the "for received in rx {}" blocking?
@jabuci
Жыл бұрын
yes, it's blocking
What?? Why would someone decide to shorten "receive" to "recv"?? It's only 7 letters like "channel" xD
@sohn7767
2 жыл бұрын
Rust likes to abbreviate that stuff. Mod, pub, etc. Surprised return isn’t called ret lol
@PhilippeCarphin
Жыл бұрын
I think it's a tradition thing in this particular case. Like the recv()/send() socket functions in the standard C library, or MPI_recv(), MPI_send().
You need to stop posting videos so fast. I haven't been to the bathroom in days, my wife has left me and the food is running out.
cloning variables and channels, seems horrible inefficient. How is rust performant. Seems like it is waisting plenty of memory.