• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::runtime::{self, Runtime};
2 
3 use std::sync::Arc;
4 
5 #[test]
blocking_shutdown()6 fn blocking_shutdown() {
7     loom::model(|| {
8         let v = Arc::new(());
9 
10         let rt = mk_runtime(1);
11         {
12             let _enter = rt.enter();
13             for _ in 0..2 {
14                 let v = v.clone();
15                 crate::task::spawn_blocking(move || {
16                     assert!(1 < Arc::strong_count(&v));
17                 });
18             }
19         }
20 
21         drop(rt);
22         assert_eq!(1, Arc::strong_count(&v));
23     });
24 }
25 
mk_runtime(num_threads: usize) -> Runtime26 fn mk_runtime(num_threads: usize) -> Runtime {
27     runtime::Builder::new_multi_thread()
28         .worker_threads(num_threads)
29         .build()
30         .unwrap()
31 }
32