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 unwinding because of panic.
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 park_timeout(dur: Duration)
Block unless or until the current thread's token is made available or the specified duration has been reached (may wake spuriously).
The semantics of this function are equivalent to park() except that the
thread will be blocked for roughly no longer than dur. This method
should not be used for precise timing due to anomalies such as
preemption or platform differences that may not cause the maximum
amount of time waited to be precisely dur
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.