@@ -20,26 +20,26 @@ pub struct Scope<'env> {
20
20
pub struct ScopedJoinHandle < ' scope , T > ( JoinInner < ' scope , T > ) ;
21
21
22
22
pub ( super ) struct ScopeData {
23
- n_running_threads : AtomicUsize ,
23
+ num_running_threads : AtomicUsize ,
24
24
a_thread_panicked : AtomicBool ,
25
25
main_thread : Thread ,
26
26
}
27
27
28
28
impl ScopeData {
29
- pub ( super ) fn increment_n_running_threads ( & self ) {
29
+ pub ( super ) fn increment_num_running_threads ( & self ) {
30
30
// We check for 'overflow' with usize::MAX / 2, to make sure there's no
31
31
// chance it overflows to 0, which would result in unsoundness.
32
- if self . n_running_threads . fetch_add ( 1 , Ordering :: Relaxed ) > usize:: MAX / 2 {
32
+ if self . num_running_threads . fetch_add ( 1 , Ordering :: Relaxed ) > usize:: MAX / 2 {
33
33
// This can only reasonably happen by mem::forget()'ing many many ScopedJoinHandles.
34
- self . decrement_n_running_threads ( false ) ;
34
+ self . decrement_num_running_threads ( false ) ;
35
35
panic ! ( "too many running threads in thread scope" ) ;
36
36
}
37
37
}
38
- pub ( super ) fn decrement_n_running_threads ( & self , panic : bool ) {
38
+ pub ( super ) fn decrement_num_running_threads ( & self , panic : bool ) {
39
39
if panic {
40
40
self . a_thread_panicked . store ( true , Ordering :: Relaxed ) ;
41
41
}
42
- if self . n_running_threads . fetch_sub ( 1 , Ordering :: Release ) == 1 {
42
+ if self . num_running_threads . fetch_sub ( 1 , Ordering :: Release ) == 1 {
43
43
self . main_thread . unpark ( ) ;
44
44
}
45
45
}
98
98
{
99
99
let scope = Scope {
100
100
data : ScopeData {
101
- n_running_threads : AtomicUsize :: new ( 0 ) ,
101
+ num_running_threads : AtomicUsize :: new ( 0 ) ,
102
102
main_thread : current ( ) ,
103
103
a_thread_panicked : AtomicBool :: new ( false ) ,
104
104
} ,
@@ -109,7 +109,7 @@ where
109
109
let result = catch_unwind ( AssertUnwindSafe ( || f ( & scope) ) ) ;
110
110
111
111
// Wait until all the threads are finished.
112
- while scope. data . n_running_threads . load ( Ordering :: Acquire ) != 0 {
112
+ while scope. data . num_running_threads . load ( Ordering :: Acquire ) != 0 {
113
113
park ( ) ;
114
114
}
115
115
@@ -287,7 +287,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
287
287
impl < ' env > fmt:: Debug for Scope < ' env > {
288
288
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
289
289
f. debug_struct ( "Scope" )
290
- . field ( "n_running_threads " , & self . data . n_running_threads . load ( Ordering :: Relaxed ) )
290
+ . field ( "num_running_threads " , & self . data . num_running_threads . load ( Ordering :: Relaxed ) )
291
291
. field ( "a_thread_panicked" , & self . data . a_thread_panicked )
292
292
. field ( "main_thread" , & self . data . main_thread )
293
293
. finish_non_exhaustive ( )
0 commit comments