Struct snarkvm_wasm::thread::ScopedJoinHandle
1.63.0 · source · pub struct ScopedJoinHandle<'scope, T>(_);Expand description
An owned permission to join on a scoped thread (block on its termination).
See Scope::spawn for details.
Implementations
sourceimpl<'scope, T> ScopedJoinHandle<'scope, T>
impl<'scope, T> ScopedJoinHandle<'scope, T>
sourcepub fn thread(&self) -> &Thread
pub fn thread(&self) -> &Thread
Extracts a handle to the underlying thread.
Examples
use std::thread;
thread::scope(|s| {
let t = s.spawn(|| {
println!("hello");
});
println!("thread id: {:?}", t.thread().id());
});sourcepub fn join(self) -> Result<T, Box<dyn Any + Send + 'static, Global>>
pub fn join(self) -> Result<T, Box<dyn Any + Send + 'static, Global>>
Waits for the associated thread to finish.
This function will return immediately if the associated thread has already finished.
In terms of atomic memory orderings, the completion of the associated
thread synchronizes with this function returning.
In other words, all operations performed by that thread
happen before
all operations that happen after join returns.
If the associated thread panics, Err is returned with the panic payload.
Examples
use std::thread;
thread::scope(|s| {
let t = s.spawn(|| {
panic!("oh no");
});
assert!(t.join().is_err());
});sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Checks if the associated thread has finished running its main function.
is_finished supports implementing a non-blocking join operation, by checking
is_finished, and calling join if it returns false. This function does not block. To
block while waiting on the thread to finish, use join.
This might return true for a brief moment after the thread’s main
function has returned, but before the thread itself has stopped running.
However, once this returns true, join can be expected
to return quickly, without blocking for any significant amount of time.
Trait Implementations
Auto Trait Implementations
impl<'scope, T> !RefUnwindSafe for ScopedJoinHandle<'scope, T>
impl<'scope, T> Send for ScopedJoinHandle<'scope, T>where
T: Send + Sync,
impl<'scope, T> Sync for ScopedJoinHandle<'scope, T>where
T: Send + Sync,
impl<'scope, T> Unpin for ScopedJoinHandle<'scope, T>
impl<'scope, T> !UnwindSafe for ScopedJoinHandle<'scope, T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;