solana_type_overrides::thread

Struct ScopedJoinHandle

1.63.0 · Source
pub struct ScopedJoinHandle<'scope, T>(/* private fields */);
Expand description

An owned permission to join on a scoped thread (block on its termination).

See Scope::spawn for details.

Implementations§

Source§

impl<'scope, T> ScopedJoinHandle<'scope, T>

1.63.0 · Source

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());
});
1.63.0 · Source

pub fn join(self) -> Result<T, Box<dyn Any + Send>>

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());
});
1.63.0 · Source

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 true. 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§

1.63.0 · Source§

impl<'scope, T> Debug for ScopedJoinHandle<'scope, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'scope, T> Freeze for ScopedJoinHandle<'scope, T>

§

impl<'scope, T> !RefUnwindSafe for ScopedJoinHandle<'scope, T>

§

impl<'scope, T> Send for ScopedJoinHandle<'scope, T>
where T: Send,

§

impl<'scope, T> Sync for ScopedJoinHandle<'scope, T>
where T: Send,

§

impl<'scope, T> Unpin for ScopedJoinHandle<'scope, T>

§

impl<'scope, T> !UnwindSafe for ScopedJoinHandle<'scope, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V