Lock::GlobalRead::GlobalRead(Locker* lockState, unsigned timeoutms) : ScopedLock(lockState) { LockResult result = _lockState->lockGlobal(MODE_S, timeoutms); if (result == LOCK_TIMEOUT) { throw DBTryLockTimeoutException(); } }
Lock::GlobalRead::GlobalRead(Locker* lockState, unsigned timeoutms) : ScopedLock(lockState, 'R') { TrackLockAcquireTime a('R'); newlm::LockResult result = _lockState->lockGlobal(newlm::MODE_S, timeoutms); if (result == newlm::LOCK_TIMEOUT) { throw DBTryLockTimeoutException(); } resetTime(); }
Lock::GlobalRead::GlobalRead( int timeoutms ) : ScopedLock( 'R' ) { LockState& ls = lockState(); char ts = ls.threadState(); noop = false; if( ts == 'R' || ts == 'W' ) { noop = true; return; } Acquiring a(this,ls); if ( timeoutms != -1 ) { bool success = qlk.lock_R_try( timeoutms ); if ( !success ) throw DBTryLockTimeoutException(); } else { qlk.lock_R(); // we are unlocked in the qlock/top sense. lock_R will assert if we are in an in compatible state } }
Lock::GlobalWrite::GlobalWrite(bool sg, int timeoutms) : ScopedLock('W') { char ts = threadState(); noop = false; if( ts == 'W' ) { noop = true; return; } dassert( ts == 0 ); Acquiring a(this,lockState()); if ( timeoutms != -1 ) { bool success = qlk.lock_W_try( timeoutms ); if ( !success ) throw DBTryLockTimeoutException(); } else { qlk.lock_W(); } }
Lock::GlobalRead::GlobalRead(LockState* lockState, int timeoutms) : ScopedLock(lockState, 'R') { char ts = _lockState->threadState(); noop = false; if( ts == 'R' || ts == 'W' ) { noop = true; return; } Acquiring a(this, *_lockState); if ( timeoutms != -1 ) { bool success = qlk.lock_R_try(_lockState, timeoutms); if ( !success ) throw DBTryLockTimeoutException(); } else { // we are unlocked in the qlock/top sense. lock_R will assert if we are in an in compatible state qlk.lock_R(_lockState); } }