]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/thread/scoped.rs
Fix typo in Scope::spawn docs.
[rust.git] / library / std / src / thread / scoped.rs
index cb5f48e5107d46ad9818e27a560865e1a8c0b93d..701850b42dcf6864b95098eb7aebdf9615360029 100644 (file)
@@ -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");
@@ -50,7 +50,7 @@ pub(super) fn decrement_n_running_threads(&self, panic: bool) {
 /// The function passed to `scope` will be provided a [`Scope`] object,
 /// through which scoped threads can be [spawned][`Scope::spawn`].
 ///
-/// Unlike non-scoped threads, scoped threads can non-`'static` data,
+/// Unlike non-scoped threads, scoped threads can borrow non-`'static` data,
 /// as the scope guarantees all threads will be joined at the end of the scope.
 ///
 /// All threads spawned within the scope that haven't been manually joined
@@ -144,7 +144,7 @@ impl<'env> Scope<'env> {
     ///
     /// # Panics
     ///
-    /// Panics if the OS fails to create a thread; use [`Builder::spawn`]
+    /// Panics if the OS fails to create a thread; use [`Builder::spawn_scoped`]
     /// to recover from such errors.
     ///
     /// [`join`]: ScopedJoinHandle::join
@@ -274,7 +274,7 @@ pub fn join(self) -> Result<T> {
         self.0.join()
     }
 
-    /// Checks if the the associated thread is still running its main function.
+    /// Checks if the associated thread is still running its main function.
     ///
     /// This might return `false` for a brief moment after the thread's main
     /// function has returned, but before the thread itself has stopped running.