Struct

std::thread::Thread!

source
forall Ret.
struct Thread! { ... }

A thread spawn started, whose closure returns a Ret; join waits for it.

Methods

method joinsource

fn join(self) -> Ret { ... }

Blocks until the thread exits, consuming the handle, and returns the Ret value f produced, so every thread's result reaches exactly one join. Safe, unlike libc::thread::Thread!::join: no raw pointer escapes, and the pointer read back is the ResultBox[Ret] trampoline built for this same Ret, which nothing else writes through. The box is freed after unboxing.

pthread_join fails only for a thread that is not joinable, is the caller, or would deadlock, and a Thread! is none of these: a thread spawn started, joined once, by a thread that holds its handle and so is not it. A failure would leave the result unreachable, so it traps rather than return without one.