4 ms·
> Outlawing concurrent shared state means that every communication between two threads needs to be formatted as a "message" in whatever abstraction is in use.
by justinpombrio 6y ago
> Outlawing concurrent shared state means that every communication between two threads needs to be formatted as a "message" in whatever abstraction is in use.
> It's a real requirement, and Rust has little to say about it in its standard library
So, I don't know much about concurrency, but you're looking for like, a Mutex, right? They're in the standard library and used all the time.
https://doc.rust-lang.org/stable/std/sync/struct.Mutex.html https://doc.rust-lang.org/stable/std/sync/struct.Mutex.html
And RwLock, a variant on Mutex that allows either one writer or multiple concurrent readers:
https://doc.rust-lang.org/stable/std/sync/struct.RwLock.html https://doc.rust-lang.org/stable/std/sync/struct.RwLock.html
- lubesGordi 6y agoYes! There's nothing weird about rust's synchronization on shared state. If you have a mutex, you can do what you want just like in c++. The mpsc::channel thing that gpp might be talking about is just a nice to have tool for sending data between threads. No one is forcing its use.