예제 #1
0
 static void lock_W() { 
     LockState& ls = lockState();
     if( ls.threadState == 't' ) { 
         DEV warning() << "W locking inside a temprelease, seems nonideal" << endl;
     }
     else if(  ls.threadState ) {
         log() << "can't lock_W, threadState=" << (int) ls.threadState << endl;
         fassert(0,false);
     }
     getDur().commitIfNeeded(); // check before locking - will use an R lock for the commit if need to do one, which is better than W
     threadState() = 'W';
     {
         Acquiring a('W');
         q.lock_W();
     }
     locked_W();
 }
예제 #2
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();
        }
    }
예제 #3
0
 void Lock::GlobalRead::_tempRelease() { 
     fassert(16127, !noop);
     char ts = threadState();
     fassert(16128, ts == 'R');
     qlk.unlock_R();
 }
예제 #4
0
 bool Lock::isR() { 
     return threadState() == 'R';
 }
예제 #5
0
 bool Lock::isW() { 
     return threadState() == 'W';
 }
예제 #6
0
 bool Lock::isRW() {
     return threadState() == 'W' || threadState() == 'R';
 }
예제 #7
0
 static void unlock_w() { 
     unlocking_w();
     wassert( threadState() == 'w' );
     threadState() = 0;
     q.unlock_w();
 }
예제 #8
0
int KNMusicStandardBackend::state() const
{
    return threadState(m_main);
}
예제 #9
0
 int Lock::isLocked() {
     return threadState();
 }
예제 #10
0
 void Lock::ThreadSpanningOp::handoffR() {
     threadState() = 0;
 }
예제 #11
0
 void Lock::ThreadSpanningOp::unsetR() {
     assert( threadState() == 'R' || threadState() == 0 ); 
     q.unlock_R();
     q.start_greed();
     threadState() = 0;
 }
예제 #12
0
 void Lock::ThreadSpanningOp::unsetW() { // note there is no unlocking_W() call here
     assert( threadState() == 'W' );
     q.unlock_W();
     q.start_greed();
     threadState() = 0;
 }
예제 #13
0
 void Lock::ThreadSpanningOp::W_to_R() { 
     assert( threadState() == 'W' );
     dur::assertNothingSpooled();
     q.W_to_R();
     threadState() = 'R';
 }
예제 #14
0
 // these are safe for use ACROSS threads.  i.e. one thread can lock and 
 // another unlock
 void Lock::ThreadSpanningOp::setWLockedNongreedy() { 
     assert( threadState() == 0 ); // as this spans threads the tls wouldn't make sense
     lock_W_stop_greed();
 }
예제 #15
0
 static void unlock_r() { 
     wassert( threadState() == 'r' );
     threadState() = 0;
     q.unlock_r();
 }
예제 #16
0
 void Lock::GlobalWrite::downgrade() { 
     verify( !noop );
     verify( threadState() == 'W' );
     qlk.W_to_R();
     lockState().changeLockState( 'R' );
 }
예제 #17
0
 // you will deadlock if 2 threads doing this
 void Lock::GlobalWrite::upgrade() { 
     verify( !noop );
     verify( threadState() == 'R' );
     qlk.R_to_W();
     lockState().changeLockState( 'W' );
 }
예제 #18
0
 int Lock::isReadLocked() {
     return threadState() == 'R' || threadState() == 'r';
 }
예제 #19
0
int KNMusicStandardBackend::previewState() const
{
    return threadState(m_preview);
}
예제 #20
0
 int Lock::somethingWriteLocked() {
     return threadState() == 'W' || threadState() == 'w';
 }