/// Tries to lock the mutex synchronously.
///
/// Returns true if the lock obtained and false otherwise.
Tries to lock the mutex synchronously.
Returns true if the lock obtained and false otherwise.
Tries to lock the mutex synchronously . Returns true if the lock obtained and false otherwise .
fn try_lock_sync(&mut self) -> bool {
        // The lock can only be obtained synchronously if
        // - it is not locked
        // - the Semaphore is either not fair, or there are no waiters
        // - required_permits == 0
        if !self.is_locked && (!self.is_fair || self.waiters.is_empty()) {
            self.is_locked = true;
            true
        } else {
            false
        }
    }
fn try_lock_sync ( & mut self ) -> bool { // The lock can only be obtained synchronously if // - it is not locked // - the Semaphore is either not fair, or there are no waiters // - required_permits == 0 if ! self . is_locked && ( ! self . is_fair || self . waiters . is_empty ( ) ) { self . is_locked = true ; true } else { false } }
Tries to lock the mutex synchronously.
Tries to lock the mutex synchronously .
&mut self