Struct std::rt::thread::Thread[src]

pub struct Thread<T> {
    // some fields omitted
}

This struct represents a native thread's state. This is used to join on an existing thread created in the join-able state.

Methods

impl Thread<()>

fn start<T: Send>(main: proc(): Send -> T) -> Thread<T>

Starts execution of a new OS thread.

This function will not wait for the thread to join, but a handle to the thread will be returned.

Note that the handle returned is used to acquire the return value of the procedure main. The join function will wait for the thread to finish and return the value that main generated.

Also note that the Thread returned will always wait for the thread to finish executing. This means that even if join is not explicitly called, when the Thread falls out of scope its destructor will block waiting for the OS thread.

fn start_stack<T: Send>(stack: uint, main: proc(): Send -> T) -> Thread<T>

Performs the same functionality as start, but specifies an explicit stack size for the new thread.

fn spawn(main: proc(): Send)

This will spawn a new thread, but it will not wait for the thread to finish, nor is it possible to wait for the thread to finish.

This corresponds to creating threads in the 'detached' state on unix systems. Note that platforms may not keep the main program alive even if there are detached thread still running around.

fn spawn_stack(stack: uint, main: proc(): Send)

Performs the same functionality as spawn, but explicitly specifies a stack size for the new thread.

fn yield_now()

Relinquishes the CPU slot that this OS-thread is currently using, allowing another thread to run for awhile.

impl<T: Send> Thread<T>

fn join<T: Send>(self) -> T

Wait for this thread to finish, returning the result of the thread's calculation.

Trait Implementations

impl<T: Send> Drop for Thread<T>

fn drop<T: Send>(&mut self)