cross_thread_drop.rs 917 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. extern crate ralloc;
  2. #[global_allocator]
  3. static ALLOCATOR: ralloc::Allocator = ralloc::Allocator;
  4. mod util;
  5. use std::thread;
  6. #[test]
  7. #[ignore]
  8. fn cross_thread_drop() {
  9. util::multiply(|| {
  10. let mut join = Vec::new();
  11. for _ in 0..10 {
  12. let bx = Box::new(0x11FE15C001u64);
  13. join.push(thread::spawn(move || {
  14. util::acid(|| {
  15. assert_eq!(*bx, 0x11FE15C001);
  16. });
  17. }));
  18. }
  19. for i in join {
  20. i.join().unwrap();
  21. }
  22. });
  23. }
  24. #[test]
  25. fn cross_thread_drop_2() {
  26. util::multiply(|| {
  27. for _ in 0..10 {
  28. let bx =
  29. thread::spawn(|| Box::new(0x11FE15C001u64)).join().unwrap();
  30. thread::spawn(move || {
  31. util::acid(|| {
  32. assert_eq!(*bx, 0x11FE15C001);
  33. });
  34. });
  35. }
  36. });
  37. }