Struct std::thread::JoinGuard
[−]
[src]
#[must_use = "thread will be immediately joined if `JoinGuard` is not used"] pub struct JoinGuard<'a, T: Send + 'a> { // some fields omitted }
: memory unsafe if destructor is avoided, see #24292
An RAII-style guard that will block until thread termination when dropped.
The type T
is the return type for the thread's main function.
Joining on drop is necessary to ensure memory safety when stack data is shared between a parent and child thread.
Due to platform restrictions, it is not possible to Clone
this
handle: the ability to join a child thread is a uniquely-owned
permission.
Methods
impl<'a, T: Send + 'a> JoinGuard<'a, T>
fn thread(&self) -> &Thread
Extracts a handle to the thread this guard will join on.
fn join(self) -> T
Waits for the associated thread to finish, returning the result of the thread's calculation.
Panics
Panics on the child thread are propagated by panicking the parent.