pub struct ScopedJoinHandle<'scope, T> { /* private fields */ }
Expand description
A handle that can be used to join its scoped thread.
This struct is created by the Scope::spawn
method and the
ScopedThreadBuilder::spawn
method.
Implementations§
Source§impl<T> ScopedJoinHandle<'_, T>
impl<T> ScopedJoinHandle<'_, T>
Sourcepub fn join(self) -> Result<T, Box<dyn Any + Send>>
pub fn join(self) -> Result<T, Box<dyn Any + Send>>
Waits for the thread to finish and returns its result.
If the child thread panics, an error is returned. Note that if panics are implemented by aborting the process, no error is returned; see the notes of std::panic::catch_unwind.
§Panics
This function may panic on some platforms if a thread attempts to join itself or otherwise may create a deadlock with joining threads.
§Examples
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 :("));
// Join the first thread and verify that it succeeded.
let res = handle1.join();
assert!(res.is_ok());
// Join the second thread and verify that it panicked.
let res = handle2.join();
assert!(res.is_err());
}).unwrap();
Trait Implementations§
Source§impl<T> Debug for ScopedJoinHandle<'_, T>
impl<T> Debug for ScopedJoinHandle<'_, T>
Source§impl<T> JoinHandleExt for ScopedJoinHandle<'_, T>
impl<T> JoinHandleExt for ScopedJoinHandle<'_, T>
Source§fn as_pthread_t(&self) -> u64
fn as_pthread_t(&self) -> u64
Source§fn into_pthread_t(self) -> u64
fn into_pthread_t(self) -> u64
impl<T> Send for ScopedJoinHandle<'_, T>
impl<T> Sync for ScopedJoinHandle<'_, T>
Auto Trait Implementations§
impl<'scope, T> Freeze for ScopedJoinHandle<'scope, T>
impl<'scope, T> RefUnwindSafe for ScopedJoinHandle<'scope, T>
impl<'scope, T> Unpin for ScopedJoinHandle<'scope, T>
impl<'scope, T> UnwindSafe for ScopedJoinHandle<'scope, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes