Skip to content

Commit 2c8cc70

Browse files
Use > rather than == for overflow check in scoped threads.
Co-authored-by: Jacob Lifshay <[email protected]>
1 parent c5cb2de commit 2c8cc70

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/std/src/thread/scoped.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl ScopeData {
2929
pub(super) fn increment_n_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.n_running_threads.fetch_add(1, Ordering::Relaxed) > usize::MAX / 2 {
3333
// This can only reasonably happen by mem::forget()'ing many many ScopedJoinHandles.
3434
self.decrement_n_running_threads(false);
3535
panic!("too many running threads in thread scope");

0 commit comments

Comments
 (0)