Created
February 6, 2026 18:28
-
-
Save Narrator/09f0694ba40764d2b7342227924ea4cc to your computer and use it in GitHub Desktop.
Isolation in rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Shared fate: threads in one process | |
| let data = Arc::new(Mutex::new(vec![])); | |
| thread::spawn({ | |
| let data = data.clone(); | |
| move || { | |
| let mut d = data.lock().unwrap(); | |
| panic!("oops"); // Mutex now poisoned for everyone | |
| } | |
| }); | |
| // Isolated: separate processes | |
| Command::new("./worker") | |
| .spawn() | |
| .expect("failed to spawn"); | |
| // Worker crashes? Main process is fine. Restart the worker. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment