pub trait ExtThread: Sealed {
// Provided methods
fn current() -> Thread ⓘ { ... }
fn panicking() -> bool { ... }
fn parallelism() -> Result<usize, IoError> ⓘ { ... }
fn park() { ... }
fn park_timeout(duration: Duration) { ... }
fn scope<'env, F, T>(f: F) -> T
where F: for<'scope> FnOnce(&'scope ThreadScope<'scope, 'env>) -> T { ... }
fn sleep(duration: Duration) { ... }
fn spawn<F, T>(f: F) -> ThreadJoinHandle<T>
where F: FnOnce() -> T + Send + 'static,
T: Send + 'static { ... }
fn yield_now() { ... }
}
Expand description
Extension trait providing additional methods for Thread
s.
Provided Methods§
Sourcefn current() -> Thread ⓘ
fn current() -> Thread ⓘ
Gets a handle to the thread that invokes it.
See std::thread::
current.
Sourcefn panicking() -> bool
fn panicking() -> bool
Determines whether the current thread is unwinding because of panic.
See std::thread::
panicking.
Sourcefn parallelism() -> Result<usize, IoError> ⓘ
fn parallelism() -> Result<usize, IoError> ⓘ
Returns an estimate of the default amount of parallelism a program should use.
See std::thread::
available_parallelism.
Sourcefn park()
fn park()
Blocks unless or until the current thread’s token is made available.
See std::thread::
park.
Sourcefn park_timeout(duration: Duration)
fn park_timeout(duration: Duration)
Blocks unless or until the current thread’s token is made available or the specified duration has been reached (may wake spuriously).
See std::thread::
park_timeout.
Sourcefn scope<'env, F, T>(f: F) -> Twhere
F: for<'scope> FnOnce(&'scope ThreadScope<'scope, 'env>) -> T,
fn scope<'env, F, T>(f: F) -> Twhere
F: for<'scope> FnOnce(&'scope ThreadScope<'scope, 'env>) -> T,
Create a scope for spawning scoped threads.
See std::thread::
scope.
Sourcefn sleep(duration: Duration)
fn sleep(duration: Duration)
Puts the current thread to sleep for at least the specified amount of time.
See std::thread::
sleep.
Sourcefn spawn<F, T>(f: F) -> ThreadJoinHandle<T>
fn spawn<F, T>(f: F) -> ThreadJoinHandle<T>
Spawns a new thread, returning a ThreadJoinHandle
for it.
See std::thread::
spawn.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.