private final Result tryLockForUpgrade_ ( L locker ) { int state = mState ; if ( ( state & LOCK_STATE_MASK ) == 0 ) { // no write or upgrade lock is held if ( isUpgradeFirst ( ) ) { do { if ( setUpgradeLock ( state ) ) { mOwner = locker ; incrementUpgradeCount ( ) ; return Result . ACQUIRED ; } // keep looping on CAS failure if a reader mucked with the state } while ( ( ( state = mState ) & LOCK_STATE_MASK ) == 0 ) ; } } else if ( mOwner == locker ) { incrementUpgradeCount ( ) ; return Result . OWNED ; } return Result . FAILED ; }
Attempt to immediately acquire an upgrade lock .