Struct std::thread::ScopedJoinHandle
source · [−]pub struct ScopedJoinHandle<'scope, T>(_);
Expand description
An owned permission to join on a scoped thread (block on its termination).
See Scope::spawn
for details.
Implementations
sourceimpl<'scope, T> ScopedJoinHandle<'scope, T>
impl<'scope, T> ScopedJoinHandle<'scope, T>
sourcepub fn join(self) -> Result<T>
pub fn join(self) -> Result<T>
Waits for the associated thread to finish.
This function will return immediately if the associated thread has already finished.
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 join
returns.
If the associated thread panics, Err
is returned with the panic payload.
Examples
#![feature(scoped_threads)]
#![feature(thread_is_running)]
use std::thread;
thread::scope(|s| {
let t = s.spawn(|_| {
panic!("oh no");
});
assert!(t.join().is_err());
});
Runsourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Checks if 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.
Trait Implementations
Auto Trait Implementations
impl<'scope, T> !RefUnwindSafe for ScopedJoinHandle<'scope, T>
impl<'scope, T> Send for ScopedJoinHandle<'scope, T> where
T: Send + Sync,
impl<'scope, T> Sync for ScopedJoinHandle<'scope, T> where
T: Send + Sync,
impl<'scope, T> Unpin for ScopedJoinHandle<'scope, T>
impl<'scope, T> !UnwindSafe for ScopedJoinHandle<'scope, T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more