Add ScopedJoinHandle::is_running().
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::io;
|
|||||||
use crate::marker::PhantomData;
|
use crate::marker::PhantomData;
|
||||||
use crate::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
|
use crate::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
|
||||||
use crate::sync::atomic::{AtomicUsize, Ordering};
|
use crate::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use crate::sync::Mutex;
|
use crate::sync::{Arc, Mutex};
|
||||||
|
|
||||||
/// TODO: documentation
|
/// TODO: documentation
|
||||||
pub struct Scope<'env> {
|
pub struct Scope<'env> {
|
||||||
@@ -114,6 +114,15 @@ impl<'scope, T> ScopedJoinHandle<'scope, T> {
|
|||||||
pub fn thread(&self) -> &Thread {
|
pub fn thread(&self) -> &Thread {
|
||||||
&self.0.thread
|
&self.0.thread
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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 = "90470")]
|
||||||
|
pub fn is_running(&self) -> bool {
|
||||||
|
Arc::strong_count(&self.0.packet) > 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'env> fmt::Debug for Scope<'env> {
|
impl<'env> fmt::Debug for Scope<'env> {
|
||||||
|
|||||||
Reference in New Issue
Block a user