pub struct Thread { /* private fields */ }Expand description
A handle to a thread.
Threads are represented via the Thread type, which you can get in one of
two ways:
- By spawning a new thread, e.g., using the
thread::spawnfunction, and callingthreadon theJoinHandle. - By requesting the current thread, using the
thread::currentfunction.
The thread::current function is available even for threads not spawned
by the APIs of this module.
There is usually no need to create a Thread struct yourself, one
should instead use a function like spawn to create new threads, see the
docs of Builder and spawn for more details.
Implementations§
Source§impl Thread
impl Thread
Sourcepub fn unpark(&self)
pub fn unpark(&self)
Atomically makes the handle’s token available if it is not already.
Every thread is equipped with some basic low-level blocking support, via
the park function and the unpark() method. These can be
used as a more CPU-efficient implementation of a spinlock.
See the park documentation for more details.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Thread
impl RefUnwindSafe for Thread
impl Send for Thread
impl Sync for Thread
impl Unpin for Thread
impl UnwindSafe for Thread
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more