deallocate_zeroed

Trait Lock

Source
pub unsafe trait Lock {
    // Required methods
    fn lock(&self);
    fn unlock(&self);
}
Expand description

A trait for providing mutual exclusion.

If you do not need to use the allocator, and collections using it, in a multi-threaded environment, you may use SingleThreadedLock, which is the moral equivalent of a RefCell.

§Safety

  • If the implementation type is Sync, then an allocator using this locking mechanism will be Sync, and therefore this method must provide actual mutual exclusion and prevent against unsynchronized accesses.

  • Even in single-threaded contexts, where real synchronization is not required, this type must prevent recursive locking and re-entering the lock when it is already held. The prevention may be a panic, abort, infinite loop, or etc…

Required Methods§

Source

fn lock(&self)

Lock this mutex.

If it is already locked, this must result in a panic, abort, infinite loop, or etc… and locking must not succeed.

Source

fn unlock(&self)

Unlock this mutex.

Implementors§