Struct std::thread::ThreadStable [-]  [+] [src]

pub struct Thread {
    // some fields omitted
}

A handle to a thread.

Methods

impl Thread

fn spawn<F>(f: F) -> Thread where F: FnOnce(), F: Send + 'static

Spawn a new detached thread, returning a handle to it.

The child thread may outlive the parent (unless the parent thread is the main thread; the whole process is terminated when the main thread finishes.) The thread handle can be used for low-level synchronization. See the module documentation for additional details.

fn scoped<'a, T, F>(f: F) -> JoinGuard<'a, T> where T: Send + 'a, F: FnOnce() -> T, F: Send + 'a

Spawn a new scoped thread, returning a JoinGuard for it.

The join guard can be used to explicitly join the child thread (via join), returning Result<T>, or it will implicitly join the child upon being dropped. Because the child thread may refer to data on the current thread's stack (hence the "scoped" name), it cannot be detached; it must be joined before the relevant stack frame is popped. See the module documentation for additional details.

fn current() -> Thread

Gets a handle to the thread that invokes it.

fn yield_now()

Cooperatively give up a timeslice to the OS scheduler.

fn panicking() -> bool

Determines whether the current thread is panicking.

fn park()

Block unless or until the current thread's token is made available (may wake spuriously).

See the module doc for more detail.

fn unpark(&self)

Atomically makes the handle's token available if it is not already.

See the module doc for more detail.

fn name(&self) -> Option<&str>

Get the thread's name.

Trait Implementations

impl NewThread for Thread

fn new(name: Option<String>) -> Thread

Derived Implementations

impl Clone for Thread

fn clone(&self) -> Thread

fn clone_from(&mut self, source: &Self)