summaryrefslogtreecommitdiff
path: root/samples/test/thread_drop.rs
diff options
context:
space:
mode:
Diffstat (limited to 'samples/test/thread_drop.rs')
-rw-r--r--samples/test/thread_drop.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/samples/test/thread_drop.rs b/samples/test/thread_drop.rs
new file mode 100644
index 00000000..ae2e6be4
--- /dev/null
+++ b/samples/test/thread_drop.rs
@@ -0,0 +1,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");
+}