File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,30 @@ fn shared() {
7171
7272 assert_eq ! ( Arc :: strong_count( & SHARED ) , 1 ) ;
7373
74+ {
75+ let mut scope = Scope :: new ( ) ;
76+ * SHARED . scope_mut ( & mut scope) = SHARED . clone ( ) ;
77+ let scope = Arc :: new ( scope) ;
78+
79+ let handles: Vec < _ > = ( 0 ..10 )
80+ . map ( |_| {
81+ let scope = scope. clone ( ) ;
82+ thread:: spawn ( move || {
83+ unsafe { ActiveScope :: set ( & scope) } ;
84+ assert_eq ! ( Arc :: strong_count( & SHARED ) , 2 ) ;
85+ assert_eq ! ( * SHARED , Arc :: new( "qwq" . to_string( ) ) ) ;
86+ ActiveScope :: set_global ( ) ;
87+ } )
88+ } )
89+ . collect ( ) ;
90+
91+ for h in handles {
92+ h. join ( ) . unwrap ( ) ;
93+ }
94+ }
95+
96+ assert_eq ! ( Arc :: strong_count( & SHARED ) , 1 ) ;
97+
7498 let panic = panic:: catch_unwind ( || {
7599 let mut scope = Scope :: new ( ) ;
76100 * SHARED . scope_mut ( & mut scope) = SHARED . clone ( ) ;
You can’t perform that action at this time.
0 commit comments