diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2022-01-04 15:58:29 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-04 15:58:29 +0000 |
| commit | 2c8cc70ea045e3d22ccb3eacb83bb748c717abc7 (patch) | |
| tree | e670dbffebcaa8627383888521ab1c1197541c63 /library/std/src | |
| parent | c5cb2def06c210a99a7299cfed67826b22452cf8 (diff) | |
| download | rust-2c8cc70ea045e3d22ccb3eacb83bb748c717abc7.tar.gz rust-2c8cc70ea045e3d22ccb3eacb83bb748c717abc7.zip | |
Use > rather than == for overflow check in scoped threads.
Co-authored-by: Jacob Lifshay <programmerjake@gmail.com>
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/thread/scoped.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/thread/scoped.rs b/library/std/src/thread/scoped.rs index cb5f48e5107..cc44eccc0a0 100644 --- a/library/std/src/thread/scoped.rs +++ b/library/std/src/thread/scoped.rs @@ -29,7 +29,7 @@ impl ScopeData { pub(super) fn increment_n_running_threads(&self) { // We check for 'overflow' with usize::MAX / 2, to make sure there's no // chance it overflows to 0, which would result in unsoundness. - if self.n_running_threads.fetch_add(1, Ordering::Relaxed) == usize::MAX / 2 { + if self.n_running_threads.fetch_add(1, Ordering::Relaxed) > usize::MAX / 2 { // This can only reasonably happen by mem::forget()'ing many many ScopedJoinHandles. self.decrement_n_running_threads(false); panic!("too many running threads in thread scope"); |
