W3cubDocs

/Rust

Function std::thread::park

pub fn park()

Blocks unless or until the current thread's token is made available.

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.

The API is typically used by acquiring a handle to the current thread, placing that handle in a shared data structure so that other threads can find it, and then parking (in a loop with a check for the token actually being acquired).

A call to park does not guarantee that the thread will remain parked forever, and callers should be prepared for this possibility.

See the module documentation for more detail.

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/thread/fn.park.html