Skip to content

Instantly share code, notes, and snippets.

@Narrator
Created February 6, 2026 18:28
Show Gist options
  • Select an option

  • Save Narrator/09f0694ba40764d2b7342227924ea4cc to your computer and use it in GitHub Desktop.

Select an option

Save Narrator/09f0694ba40764d2b7342227924ea4cc to your computer and use it in GitHub Desktop.
Isolation in rust
// 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