pub struct ScopedJoinHandle<'scope, T> { /* fields omitted */ }
A handle that can be used to join its scoped thread.
Waits for the thread to finish and returns its result.
If the child thread panics, an error is returned.
This function may panic on some platforms if a thread attempts to join itself or otherwise
may create a deadlock with joining threads.
use crossbeam_utils::thread;
thread::scope(|s| {
let handle1 = s.spawn(|_| println!("I'm a happy thread :)"));
let handle2 = s.spawn(|_| panic!("I'm a sad thread :("));
let res = handle1.join();
assert!(res.is_ok());
let res = handle2.join();
assert!(res.is_err());
}).unwrap();
Returns a handle to the underlying thread.
use crossbeam_utils::thread;
thread::scope(|s| {
let handle = s.spawn(|_| println!("A child thread is running"));
println!("The child thread ID: {:?}", handle.thread().id());
}).unwrap();
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static