Trait parking_lot_core::thread_parker::ThreadParkerT

source ·
pub trait ThreadParkerT {
    type UnparkHandle: UnparkHandleT;

    const IS_CHEAP_TO_CONSTRUCT: bool;

    // Required methods
    fn new() -> Self;
    unsafe fn prepare_park(&self);
    unsafe fn timed_out(&self) -> bool;
    unsafe fn park(&self);
    unsafe fn park_until(&self, timeout: Instant) -> bool;
    unsafe fn unpark_lock(&self) -> Self::UnparkHandle;
}
Expand description

Trait for the platform thread parker implementation.

All unsafe methods are unsafe because the Unix thread parker is based on pthread mutexes and condvars. Those primitives must not be moved and used from any other memory address than the one they were located at when they were initialized. As such, it’s UB to call any unsafe method on ThreadParkerT if the implementing instance has moved since the last call to any of the unsafe methods.

Required Associated Types§

Required Associated Constants§

Required Methods§

source

fn new() -> Self

source

unsafe fn prepare_park(&self)

Prepares the parker. This should be called before adding it to the queue.

source

unsafe fn timed_out(&self) -> bool

Checks if the park timed out. This should be called while holding the queue lock after park_until has returned false.

source

unsafe fn park(&self)

Parks the thread until it is unparked. This should be called after it has been added to the queue, after unlocking the queue.

source

unsafe fn park_until(&self, timeout: Instant) -> bool

Parks the thread until it is unparked or the timeout is reached. This should be called after it has been added to the queue, after unlocking the queue. Returns true if we were unparked and false if we timed out.

source

unsafe fn unpark_lock(&self) -> Self::UnparkHandle

Locks the parker to prevent the target thread from exiting. This is necessary to ensure that thread-local ThreadData objects remain valid. This should be called while holding the queue lock.

Object Safety§

This trait is not object safe.

Implementors§