pub struct ContextJoinHandle<'scope, T> { /* private fields */ }
Expand description
A handle that can be used to join its context thread.
This struct is created by the Context::spawn
method and the
[ContextJoinHandle::spawn
] method.
Implementations§
Source§impl<T> ContextJoinHandle<'_, T>
impl<T> ContextJoinHandle<'_, T>
Sourcepub fn join(self) -> Result<T>
pub fn join(self) -> Result<T>
Waits for the thread to finish and returns its result.
If the child thread panics, an error is returned.
§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 ctx_thread::scope;
scope(|ctx| {
let handle1 = ctx.spawn(|_| println!("I'm a happy thread :)"));
let handle2 = ctx.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 ContextJoinHandle<'_, T>
impl<T> Debug for ContextJoinHandle<'_, T>
Source§impl<T> JoinHandleExt for ContextJoinHandle<'_, T>
impl<T> JoinHandleExt for ContextJoinHandle<'_, T>
Source§fn as_pthread_t(&self) -> RawPthread
fn as_pthread_t(&self) -> RawPthread
Extracts the raw pthread_t without taking ownership
Source§fn into_pthread_t(self) -> RawPthread
fn into_pthread_t(self) -> RawPthread
Consumes the thread, returning the raw pthread_t Read more
impl<T> Send for ContextJoinHandle<'_, T>
impl<T> Sync for ContextJoinHandle<'_, T>
Auto Trait Implementations§
impl<'scope, T> Freeze for ContextJoinHandle<'scope, T>
impl<'scope, T> RefUnwindSafe for ContextJoinHandle<'scope, T>
impl<'scope, T> Unpin for ContextJoinHandle<'scope, T>
impl<'scope, T> UnwindSafe for ContextJoinHandle<'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
Mutably borrows from an owned value. Read more