pub fn scope<'env, F, T>(f: F) -> TExpand description
Creates a scope for spawning scoped threads with deadlock detection.
This is a wrapper around std::thread::scope that adds deadlock detection
to scoped threads.
§Examples
use deloxide::thread;
use std::sync::atomic::{AtomicI32, Ordering};
let x = AtomicI32::new(0);
thread::scope(|s| {
s.spawn(|| {
x.fetch_add(1, Ordering::SeqCst);
});
s.spawn(|| {
x.fetch_add(1, Ordering::SeqCst);
});
});
assert_eq!(x.load(Ordering::SeqCst), 2);