PriorityQueue - Rust #003 - Multithreading
This video is in French.
In this video, we get into the heart of the matter: concurrency.
We start by reorganizing the project as a Cargo workspace to structure the code, then discover how Rust approaches memory safety in a multithreaded context.
Topics covered
- Why switch to a Cargo workspace
- The behavior of thread::spawn, the role of move and 'static
- The Send and Sync traits explained simply
- Why our PriorityQueue is not thread-safe as-is
- Introduction of Arc and Mutex for sharing and protecting data
- RAII, mutex poisoning, and error handling in Result/Option
A key step before tackling async (Tokio, async-std) in the next video.
Useful links
Source code: github.com/xigh/pq-async-rs