Skip to content

Commit a9efbaf

Browse files
committed
Rename n_running_threads to num_running_threads.
1 parent 5b5746f commit a9efbaf

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

library/std/src/thread/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl Builder {
505505
};
506506

507507
if let Some(scope_data) = scope_data {
508-
scope_data.increment_n_running_threads();
508+
scope_data.increment_num_running_threads();
509509
}
510510

511511
Ok(JoinInner {
@@ -1292,7 +1292,7 @@ impl<'scope, T> Drop for Packet<'scope, T> {
12921292
// panicked, and nobody consumed the panic payload, we make sure
12931293
// the scope function will panic.
12941294
let unhandled_panic = matches!(self.result.get_mut(), Some(Err(_)));
1295-
scope.decrement_n_running_threads(unhandled_panic);
1295+
scope.decrement_num_running_threads(unhandled_panic);
12961296
}
12971297
}
12981298
}

library/std/src/thread/scoped.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ pub struct Scope<'env> {
2020
pub struct ScopedJoinHandle<'scope, T>(JoinInner<'scope, T>);
2121

2222
pub(super) struct ScopeData {
23-
n_running_threads: AtomicUsize,
23+
num_running_threads: AtomicUsize,
2424
a_thread_panicked: AtomicBool,
2525
main_thread: Thread,
2626
}
2727

2828
impl ScopeData {
29-
pub(super) fn increment_n_running_threads(&self) {
29+
pub(super) fn increment_num_running_threads(&self) {
3030
// We check for 'overflow' with usize::MAX / 2, to make sure there's no
3131
// 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 {
3333
// 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);
3535
panic!("too many running threads in thread scope");
3636
}
3737
}
38-
pub(super) fn decrement_n_running_threads(&self, panic: bool) {
38+
pub(super) fn decrement_num_running_threads(&self, panic: bool) {
3939
if panic {
4040
self.a_thread_panicked.store(true, Ordering::Relaxed);
4141
}
42-
if self.n_running_threads.fetch_sub(1, Ordering::Release) == 1 {
42+
if self.num_running_threads.fetch_sub(1, Ordering::Release) == 1 {
4343
self.main_thread.unpark();
4444
}
4545
}
@@ -98,7 +98,7 @@ where
9898
{
9999
let scope = Scope {
100100
data: ScopeData {
101-
n_running_threads: AtomicUsize::new(0),
101+
num_running_threads: AtomicUsize::new(0),
102102
main_thread: current(),
103103
a_thread_panicked: AtomicBool::new(false),
104104
},
@@ -109,7 +109,7 @@ where
109109
let result = catch_unwind(AssertUnwindSafe(|| f(&scope)));
110110

111111
// 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 {
113113
park();
114114
}
115115

@@ -287,7 +287,7 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
287287
impl<'env> fmt::Debug for Scope<'env> {
288288
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
289289
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))
291291
.field("a_thread_panicked", &self.data.a_thread_panicked)
292292
.field("main_thread", &self.data.main_thread)
293293
.finish_non_exhaustive()

0 commit comments

Comments
 (0)