devela::work

Trait ExtThread

Source
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 Threads.

Provided Methods§

Source

fn current() -> Thread

Gets a handle to the thread that invokes it.

See std::thread::current.

Source

fn panicking() -> bool

Determines whether the current thread is unwinding because of panic.

See std::thread::panicking.

Source

fn parallelism() -> Result<usize, IoError>

Returns an estimate of the default amount of parallelism a program should use.

See std::thread::available_parallelism.

Source

fn park()

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

See std::thread::park.

Source

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.

Source

fn scope<'env, F, T>(f: F) -> T
where F: for<'scope> FnOnce(&'scope ThreadScope<'scope, 'env>) -> T,

Create a scope for spawning scoped threads.

See std::thread::scope.

Source

fn sleep(duration: Duration)

Puts the current thread to sleep for at least the specified amount of time.

See std::thread::sleep.

Source

fn spawn<F, T>(f: F) -> ThreadJoinHandle<T>
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,

Spawns a new thread, returning a ThreadJoinHandle for it.

See std::thread::spawn.

Source

fn yield_now()

Cooperatively gives up a timeslice to the OS scheduler.

See std::thread::yield_now.

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.

Implementors§