Struct ScopedJoinHandle
pub struct ScopedJoinHandle<'scope, T>(pub(in ::thread::scoped) JoinInner<'scope, T>);
An owned permission to join on a scoped thread (block on its termination).
See Scope::spawn for details.
Fields
0: JoinInner<'scope, T>
Implementations
impl<'scope, T> ScopedJoinHandle<'scope, T>
fn thread(&self) -> &ThreadExtracts a handle to the underlying thread.
Examples
use thread; scope;fn join(self) -> Result<T>Waits for the associated thread to finish.
This function will return immediately if the associated thread has already finished. Otherwise, it fully waits for the thread to finish, including all destructors for thread-local variables that might be running after the main function of the thread.
In terms of atomic memory orderings, the completion of the associated thread synchronizes with this function returning. In other words, all operations performed by that thread happen before all operations that happen after
joinreturns.If the associated thread panics,
Erris returned with the panic payload.Examples
use thread; scope;fn is_finished(&self) -> boolChecks if the associated thread has finished running its main function.
is_finishedsupports implementing a non-blocking join operation, by checkingis_finished, and callingjoinif it returnstrue. This function does not block. To block while waiting on the thread to finish, use [join][Self::join].This might return
truefor a brief moment after the thread's main function has returned, but before the thread itself has stopped running. However, once this returnstrue, [join][Self::join] can be expected to return quickly, without blocking for any significant amount of time.
Trait Implementations
impl<'scope, T> Debug for ScopedJoinHandle<'scope, T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<'scope, T> !RefUnwindSafe for ScopedJoinHandle<'scope, T>
impl<'scope, T> !UnwindSafe for ScopedJoinHandle<'scope, T>
impl<'scope, T> Freeze for ScopedJoinHandle<'scope, T>
where
JoinInner<'scope, T>: Freeze,
impl<'scope, T> Send for ScopedJoinHandle<'scope, T>
where
JoinInner<'scope, T>: Send,
impl<'scope, T> Sync for ScopedJoinHandle<'scope, T>
where
JoinInner<'scope, T>: Sync,
impl<'scope, T> Unpin for ScopedJoinHandle<'scope, T>
where
JoinInner<'scope, T>: Unpin,
impl<'scope, T> UnsafeUnpin for ScopedJoinHandle<'scope, T>
where
JoinInner<'scope, T>: UnsafeUnpin,
Blanket Implementations
impl<T> Any for ScopedJoinHandle<'scope, T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for ScopedJoinHandle<'scope, T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for ScopedJoinHandle<'scope, T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for ScopedJoinHandle<'scope, T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for ScopedJoinHandle<'scope, T>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for ScopedJoinHandle<'scope, T>
impl<T, U> Into<U> for ScopedJoinHandle<'scope, T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for ScopedJoinHandle<'scope, T>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for ScopedJoinHandle<'scope, T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>