Exemplo n.º 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();
 }
Exemplo n.º 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();
        }
    }
Exemplo n.º 3
0
 void Lock::GlobalRead::_tempRelease() { 
     fassert(16127, !noop);
     char ts = threadState();
     fassert(16128, ts == 'R');
     qlk.unlock_R();
 }
Exemplo n.º 4
0
 bool Lock::isR() { 
     return threadState() == 'R';
 }
Exemplo n.º 5
0
 bool Lock::isW() { 
     return threadState() == 'W';
 }
Exemplo n.º 6
0
 bool Lock::isRW() {
     return threadState() == 'W' || threadState() == 'R';
 }
Exemplo n.º 7
0
 static void unlock_w() { 
     unlocking_w();
     wassert( threadState() == 'w' );
     threadState() = 0;
     q.unlock_w();
 }
Exemplo n.º 8
0
int KNMusicStandardBackend::state() const
{
    return threadState(m_main);
}
Exemplo n.º 9
0
 int Lock::isLocked() {
     return threadState();
 }
Exemplo n.º 10
0
 void Lock::ThreadSpanningOp::handoffR() {
     threadState() = 0;
 }
Exemplo n.º 11
0
 void Lock::ThreadSpanningOp::unsetR() {
     assert( threadState() == 'R' || threadState() == 0 ); 
     q.unlock_R();
     q.start_greed();
     threadState() = 0;
 }
Exemplo n.º 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;
 }
Exemplo n.º 13
0
 void Lock::ThreadSpanningOp::W_to_R() { 
     assert( threadState() == 'W' );
     dur::assertNothingSpooled();
     q.W_to_R();
     threadState() = 'R';
 }
Exemplo n.º 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();
 }
Exemplo n.º 15
0
 static void unlock_r() { 
     wassert( threadState() == 'r' );
     threadState() = 0;
     q.unlock_r();
 }
Exemplo n.º 16
0
 void Lock::GlobalWrite::downgrade() { 
     verify( !noop );
     verify( threadState() == 'W' );
     qlk.W_to_R();
     lockState().changeLockState( 'R' );
 }
Exemplo n.º 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' );
 }
Exemplo n.º 18
0
 int Lock::isReadLocked() {
     return threadState() == 'R' || threadState() == 'r';
 }
Exemplo n.º 19
0
int KNMusicStandardBackend::previewState() const
{
    return threadState(m_preview);
}
Exemplo n.º 20
0
 int Lock::somethingWriteLocked() {
     return threadState() == 'W' || threadState() == 'w';
 }