浏览代码

Add Arc test, triggering an unusual bug.

Weird stuff. Ain't high, ain't drunk, but shit's happening, and it is fucked up. I can smell rainbows.
ticki 8 年之前
父节点
当前提交
96acdffac8
共有 1 个文件被更改,包括 21 次插入0 次删除
  1. 21 0
      tests/arc.rs

+ 21 - 0
tests/arc.rs

@@ -0,0 +1,21 @@
+//! This test is a more subtle one. It is one which can hit thread destructors unexpectedly.
+
+extern crate ralloc;
+
+use std::sync::Arc;
+use std::thread;
+
+fn main() {
+    let numbers: Vec<_> = (0..100).collect();
+    let shared_numbers = Arc::new(numbers);
+
+    for _ in 0..10 {
+        let child_numbers = shared_numbers.clone();
+
+        thread::spawn(move || {
+            let local_numbers = &child_numbers[..];
+
+            // Work with the local numbers
+        });
+    }
+}