Trait lock_api::rwlock::RawRwLockFair

source ·
pub unsafe trait RawRwLockFair: RawRwLock {
    // Required methods
    unsafe fn unlock_shared_fair(&self);
    unsafe fn unlock_exclusive_fair(&self);

    // Provided methods
    unsafe fn bump_shared(&self) { ... }
    unsafe fn bump_exclusive(&self) { ... }
}
Expand description

Additional methods for RwLocks which support fair unlocking.

Fair unlocking means that a lock is handed directly over to the next waiting thread if there is one, without giving other threads the opportunity to “steal” the lock in the meantime. This is typically slower than unfair unlocking, but may be necessary in certain circumstances.

Required Methods§

source

unsafe fn unlock_shared_fair(&self)

Releases a shared lock using a fair unlock protocol.

§Safety

This method may only be called if a shared lock is held in the current context.

source

unsafe fn unlock_exclusive_fair(&self)

Releases an exclusive lock using a fair unlock protocol.

§Safety

This method may only be called if an exclusive lock is held in the current context.

Provided Methods§

source

unsafe fn bump_shared(&self)

Temporarily yields a shared lock to a waiting thread if there is one.

This method is functionally equivalent to calling unlock_shared_fair followed by lock_shared, however it can be much more efficient in the case where there are no waiting threads.

§Safety

This method may only be called if a shared lock is held in the current context.

source

unsafe fn bump_exclusive(&self)

Temporarily yields an exclusive lock to a waiting thread if there is one.

This method is functionally equivalent to calling unlock_exclusive_fair followed by lock_exclusive, however it can be much more efficient in the case where there are no waiting threads.

§Safety

This method may only be called if an exclusive lock is held in the current context.

Object Safety§

This trait is not object safe.

Implementors§