コード例 #1
0
ファイル: d_concurrency.cpp プロジェクト: 3rf/mongo
    Lock::GlobalRead::GlobalRead(Locker* lockState, unsigned timeoutms)
        : ScopedLock(lockState) {

        LockResult result = _lockState->lockGlobal(MODE_S, timeoutms);
        if (result == LOCK_TIMEOUT) {
            throw DBTryLockTimeoutException();
        }
    }
コード例 #2
0
ファイル: d_concurrency.cpp プロジェクト: ANTco/mongo
    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();
    }
コード例 #3
0
    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
        }
    }
コード例 #4
0
    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();
        }
    }
コード例 #5
0
ファイル: d_concurrency.cpp プロジェクト: Robbie1977/mongo
    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); 
        }
    }