fn try_acquire_sync(&mut self, required_permits: usize) -> bool {
        // Permits can only be obtained synchronously if there are
        // - enough permits available
        // - the Semaphore is either not fair, or there are no waiters
        // - required_permits == 0
        if (self.permits >= required_permits)
            && (!self.is_fair
                || self.waiters.is_empty()
                || required_permits == 0)
        {
            self.permits -= required_permits;
            true
        } else {
            false
        }
    }
/// Tries to acquire the given amount of permits synchronously.
///
/// Returns true if the permits were obtained and false otherwise.
Tries to acquire the given amount of permits synchronously.
Returns true if the permits were obtained and false otherwise.
Tries to acquire the given amount of permits synchronously . Returns true if the permits were obtained and false otherwise .
fn try_acquire_sync(&mut self, required_permits: usize) -> bool {
        // Permits can only be obtained synchronously if there are
        // - enough permits available
        // - the Semaphore is either not fair, or there are no waiters
        // - required_permits == 0
        if (self.permits >= required_permits)
            && (!self.is_fair
                || self.waiters.is_empty()
                || required_permits == 0)
        {
            self.permits -= required_permits;
            true
        } else {
            false
        }
    }
fn try_acquire_sync ( & mut self , required_permits : usize ) -> bool { // Permits can only be obtained synchronously if there are // - enough permits available // - the Semaphore is either not fair, or there are no waiters // - required_permits == 0 if ( self . permits >= required_permits ) && ( ! self . is_fair || self . waiters . is_empty ( ) || required_permits == 0 ) { self . permits -= required_permits ; true } else { false } }
Tries to acquire the given amount of permits synchronously.
Tries to acquire the given amount of permits synchronously .
&mut self
required_permits
usize
&mut self
required_permits
usize