Skip to content

Commit dadf2ad

Browse files
m-ou-sejoshtriplett
andcommitted
Rename JoinHandle::is_running to is_finished and update docs.
Co-authored-by: Josh Triplett <[email protected]>
1 parent 2f8d1a8 commit dadf2ad

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

library/std/src/thread/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,13 +1443,18 @@ impl<T> JoinHandle<T> {
14431443
self.0.join()
14441444
}
14451445

1446-
/// Checks if the associated thread is still running its main function.
1446+
/// Checks if the associated thread has finished running its main function.
14471447
///
1448-
/// This might return `false` for a brief moment after the thread's main
1448+
/// This might return `true` for a brief moment after the thread's main
14491449
/// function has returned, but before the thread itself has stopped running.
1450+
/// However, once this returns `true`, [`join`][Self::join] can be expected
1451+
/// to return quickly, without blocking for any significant amount of time.
1452+
///
1453+
/// This function does not block. To block while waiting on the thread to finish,
1454+
/// use [`join`][Self::join].
14501455
#[unstable(feature = "thread_is_running", issue = "90470")]
1451-
pub fn is_running(&self) -> bool {
1452-
Arc::strong_count(&self.0.packet) > 1
1456+
pub fn is_finished(&self) -> bool {
1457+
Arc::strong_count(&self.0.packet) == 1
14531458
}
14541459
}
14551460

library/std/src/thread/scoped.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,18 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
289289
self.0.join()
290290
}
291291

292-
/// Checks if the associated thread is still running its main function.
292+
/// Checks if the associated thread has finished running its main function.
293293
///
294-
/// This might return `false` for a brief moment after the thread's main
294+
/// This might return `true` for a brief moment after the thread's main
295295
/// function has returned, but before the thread itself has stopped running.
296+
/// However, once this returns `true`, [`join`][Self::join] can be expected
297+
/// to return quickly, without blocking for any significant amount of time.
298+
///
299+
/// This function does not block. To block while waiting on the thread to finish,
300+
/// use [`join`][Self::join].
296301
#[unstable(feature = "thread_is_running", issue = "90470")]
297-
pub fn is_running(&self) -> bool {
298-
Arc::strong_count(&self.0.packet) > 1
302+
pub fn is_finished(&self) -> bool {
303+
Arc::strong_count(&self.0.packet) == 1
299304
}
300305
}
301306

0 commit comments

Comments
 (0)