starnix_sync

Function ordered_lock

Source
pub fn ordered_lock<'a, T>(
    m1: &'a Mutex<T>,
    m2: &'a Mutex<T>,
) -> (MutexGuard<'a, T>, MutexGuard<'a, T>)
Expand description

Lock m1 and m2 in a consistent order (using the memory address of m1 and m2 and returns the associated guard. This ensure that ordered_lock(m1, m2) and ordered_lock(m2, m1) will not deadlock.