Rename JoinHandle::is_running to is_finished and update docs.
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
This commit is contained in:
parent
2f8d1a835b
commit
dadf2adbe9
2 changed files with 18 additions and 8 deletions
|
|
@ -1443,13 +1443,18 @@ impl<T> JoinHandle<T> {
|
|||
self.0.join()
|
||||
}
|
||||
|
||||
/// Checks if the associated thread is still running its main function.
|
||||
/// Checks if the associated thread has finished running its main function.
|
||||
///
|
||||
/// This might return `false` for a brief moment after the thread's main
|
||||
/// This might return `true` for a brief moment after the thread's main
|
||||
/// function has returned, but before the thread itself has stopped running.
|
||||
/// However, once this returns `true`, [`join`][Self::join] can be expected
|
||||
/// to return quickly, without blocking for any significant amount of time.
|
||||
///
|
||||
/// This function does not block. To block while waiting on the thread to finish,
|
||||
/// use [`join`][Self::join].
|
||||
#[unstable(feature = "thread_is_running", issue = "90470")]
|
||||
pub fn is_running(&self) -> bool {
|
||||
Arc::strong_count(&self.0.packet) > 1
|
||||
pub fn is_finished(&self) -> bool {
|
||||
Arc::strong_count(&self.0.packet) == 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue