mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
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
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,13 +289,18 @@ impl<'scope, T> ScopedJoinHandle<'scope, 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…
Reference in New Issue
Block a user