Trait Park

Source
pub unsafe trait Park:
    'static
    + Send
    + Sync {
    // Required methods
    fn new() -> Self;
    fn park();
    fn unpark(&self);
}
Expand description

An handle used to unpark a thread.

Note that thread need not mean std::thread::Thread but could be any number of user/kernal thread implementations.

An implementation for std::thread::Thread is available behind the std feature.

Required Methods§

Source

fn new() -> Self

Returns a handle to unpark the current thread.

Source

fn park()

Parks the current thread when called.

§Safety

To avoid deadlocks occouring it is important that in the following execution order this function exists immediatly.

  • thread1 start
  • thread2 start
  • thread1 pass unpark handle to thread2
  • thread2 unparks thread1
  • thread1 attempts to park
Source

fn unpark(&self)

Unparks the thread handled by this instance when called.

See park documentation for details.

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§