File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11use std:: {
22 sync:: Arc ,
33 thread,
4+ panic,
45} ;
56
67use ctor:: ctor;
@@ -57,6 +58,31 @@ fn shared() {
5758 }
5859
5960 assert_eq ! ( Arc :: strong_count( & SHARED ) , 1 ) ;
61+
62+ let handles: Vec < _ > = ( 0 ..9 )
63+ . map ( |_| {
64+ thread:: spawn ( move || {
65+ let mut scope = Scope :: new ( ) ;
66+ * SHARED . scope_mut ( & mut scope) = SHARED . clone ( ) ;
67+ assert ! ( Arc :: strong_count( & SHARED ) >= 2 ) ;
68+ } )
69+ } )
70+ . collect ( ) ;
71+
72+ for h in handles {
73+ h. join ( ) . unwrap ( ) ;
74+ }
75+
76+ assert_eq ! ( Arc :: strong_count( & SHARED ) , 1 ) ;
77+
78+ let panic = panic:: catch_unwind ( || {
79+ let mut scope = Scope :: new ( ) ;
80+ * SHARED . scope_mut ( & mut scope) = SHARED . clone ( ) ;
81+ panic ! ( "panic" ) ;
82+ } ) ;
83+ assert ! ( panic. is_err( ) ) ;
84+
85+ assert_eq ! ( Arc :: strong_count( & SHARED ) , 1 ) ;
6086}
6187
6288#[ test]
You can’t perform that action at this time.
0 commit comments