コード例 #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';
 }