pub struct JoinHandle<T: Send + 'static> { /* private fields */ }Expand description
Handle for joining a thread
This can be used as a drop-in replacement for std::thread::JoinHandle
as long as you are not calling .thread() (which currently doesn’t have a good use case -
if you do have one please open an issue on GitHub).
JoinHandle also implements IntoFuture so you can join a thread
asynchronously by await-ing it.
Implementations§
Source§impl<T: Send + 'static> JoinHandle<T>
impl<T: Send + 'static> JoinHandle<T>
Sourcepub fn join(self) -> Result<T, Box<dyn Any + Send + 'static>>
pub fn join(self) -> Result<T, Box<dyn Any + Send + 'static>>
Block the current thread until the thread is finished. Returns the value returned by the thread’s main closure/future.
This function should behave similarly to std::thread::JoinHandle::join.
To asynchronously join the thread you can await the join handle instead of calling
.join().
§Note about panicking
If panic=abort, the panic will still be caught and this function will return
Err with a generic message, instead of triggering another panic.
For more information on unwind and catching panics, see Working with Panic in the book
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Check if the thread has finished executing, or panicked. This can be used to implement non-blocking join.