blob: ae2e6be4aadc4e5f34825091bb4b913aaac7f42c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
use std::sync::Arc;
use std::sync::atomic::{Ordering, AtomicBool};
fn main() {
struct Foo(Arc<AtomicBool>);
impl Drop for Foo {
fn drop(&mut self) {
self.0.store(true, Ordering::SeqCst);
}
}
let h = Arc::new(AtomicBool::new(false));
let h2 = Foo(h.clone());
let th = ::std::thread::spawn(move || { let _ = h2; });
th.join().unwrap();
assert!(h.load(Ordering::SeqCst), "Foo's Drop impl was never called");
}
|