We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0eefa94 commit 57b82a1Copy full SHA for 57b82a1
std/src/thread/scoped.rs
@@ -47,10 +47,16 @@ impl ScopeData {
47
// chance it overflows to 0, which would result in unsoundness.
48
if self.num_running_threads.fetch_add(1, Ordering::Relaxed) > usize::MAX / 2 {
49
// This can only reasonably happen by mem::forget()'ing a lot of ScopedJoinHandles.
50
- self.decrement_num_running_threads(false);
51
- panic!("too many running threads in thread scope");
+ self.overflow();
52
}
53
+
54
+ #[cold]
55
+ fn overflow(&self) {
56
+ self.decrement_num_running_threads(false);
57
+ panic!("too many running threads in thread scope");
58
+ }
59
60
pub(super) fn decrement_num_running_threads(&self, panic: bool) {
61
if panic {
62
self.a_thread_panicked.store(true, Ordering::Relaxed);
0 commit comments