Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add JoinHandle::is_running.
  • Loading branch information
m-ou-se committed Oct 31, 2021
commit d718b1a79508169f10cd4b691071d4308ac15fc3
9 changes: 9 additions & 0 deletions library/std/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,15 @@ impl<T> JoinHandle<T> {
pub fn join(mut self) -> Result<T> {
self.0.join()
}

/// Checks if the 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.
#[unstable(feature = "thread_is_running", issue = "none")]
pub fn is_running(&self) -> bool {
Arc::strong_count(&self.0.packet.0) > 1
}
}

impl<T> AsInner<imp::Thread> for JoinHandle<T> {
Expand Down