Struct Thread

Source
pub struct Thread<T: Send + 'static> { /* private fields */ }
Expand description

Handle on a thread returned by Builder::spawn.

Implementations§

Source§

impl<T: Send + 'static> Thread<T>

Source

pub fn join(&self) -> Result<T>

Waits for the associated thread to finish.

If the child thread panics, Err is returned with the parameter given to panic.

Source

pub fn join_timeout(&self, timeout: Duration) -> Result<T>

Similar to Thread::join but does not block forever.

Source

pub fn map<U, F>(self, f: F) -> MapThread<U>
where U: Send + 'static, F: FnMut(T) -> U + 'static,

Apply a transformation function when joining to the thread.

Source

pub fn request_shutdown(&self)

Signal the thread is should terminate as soon as possible.

NOTE: you should take precautions when implementing the thread body to periodiaclly check if it needs to terminate or not.

Source

pub fn select_add<'a>(&'a self, select: &mut Select<'a>) -> usize

Add the thread to a Select set.

Source

pub fn select_join(&self, operation: SelectedOperation<'_>) -> Result<T>

Completes a join operation that was started by the Select interface.

This method should be used if one of the select operations are used. If the ready familiy of methods is used, use one of the other join methods.

Auto Trait Implementations§

§

impl<T> !Freeze for Thread<T>

§

impl<T> !RefUnwindSafe for Thread<T>

§

impl<T> Send for Thread<T>

§

impl<T> !Sync for Thread<T>

§

impl<T> Unpin for Thread<T>

§

impl<T> !UnwindSafe for Thread<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.