lock state characteristic
343707
function LockStateCharateristic(opts) {
	LockStateCharateristic.super_.call(this, objectAssign({
		uuid: 'ee0c2081-8786-40ba-ab96-99b91ac981d8',
		properties: ['read'],
		sizeof: 1
	}, opts));
}
1128193
private static void lockBoth(Lock sourceWriteLock, Lock destWriteLock) {
    while (true) {
      sourceWriteLock.lock();
      if (destWriteLock.tryLock()) {
        return;
      } else {
        sourceWriteLock.unlock();
      }

      destWriteLock.lock();
      if (sourceWriteLock.tryLock()) {
        return;
      } else {
        destWriteLock.unlock();
      }
    }
  }
177142
boolean tryLock(long id, ItemState state, Transaction txn) {
        final CacheLine line = getLine(id);
        if (line == null)
            return false;
        synchronized (line) {
            if ((state == ItemState.OWNED & line.getState() == State.E)
                    | (state == ItemState.SHARED & !line.getState().isLessThan(State.S))) {
                lockLine(line, txn);
                return true;
            }
        }
        return false;
    }
970135
def get_lock(
        end_state: NettingChannelEndState,
        secrethash: SecretHash,
) -> Optional[HashTimeLockState]:
    
    lock = end_state.secrethashes_to_lockedlocks.get(secrethash)

    if not lock:
        partial_unlock = end_state.secrethashes_to_unlockedlocks.get(secrethash)

        if not partial_unlock:
            partial_unlock = end_state.secrethashes_to_onchain_unlockedlocks.get(secrethash)

        if partial_unlock:
            lock = partial_unlock.lock

    assert isinstance(lock, HashTimeLockState) or lock is None
    return lock
575966
public void lockAndRegister(RuntimeObject rtObject, int lockMode, List registeredObjects)
    {
        lockAndRegister(rtObject, lockMode, isImplicitLocking(), registeredObjects);
    }
1024677
def lock(self, id=str(uuid.uuid4()), ttl=DEFAULT_TIMEOUT):
        
        return Lock(id, ttl=ttl, client=self)
1101913
public boolean isInZeroBlock(int ch) 
    {
        // valid, uncompacted trie and valid c?
        if (m_isCompacted_ || ch > UCharacter.MAX_VALUE 
            || ch < UCharacter.MIN_VALUE) {
            return true;
        }
    
        return m_index_[ch >> SHIFT_] == 0;
    }
720386
def get_locked_variable(self, key, access_key):
        
        return self.get_variable(key, per_reference=False, access_key=access_key)
809519
def state(self, state):
        """"""
        with self._lock:
            self._value = self._states.index(state)
1113818
public boolean releaseLock() {
        LockInfo info = (LockInfo)mLockInfoRef.get();
        int type = info.mType;
        int count = info.mCount;
        if (count > 0) {
            count--;
        }
        else {
            info.mType = type = NONE;
            count = 0;
        }

        if ((info.mCount = count) == 0) {
            switch (type) {
            case NONE: default:
                return false;

            case READ:
                synchronized (this) {
                    mReadLocks--;
                    notifyAll();
                }
                break;

            case UPGRADABLE:
                synchronized (this) {
                    mUpgradableLockHeld = null;
                    notifyAll();
                }
                break;

            case WRITE:
                synchronized (this) {
                    mWriteLockHeld = null;
                    notifyAll();
                }
                break;
            }

            info.mType = NONE;
        }
        else if (type == WRITE && info.mUpgradeCount == count) {
            // Convert write lock back into an upgradable lock.
            info.mType = UPGRADABLE;
            info.mUpgradeCount = 0;
            synchronized (this) {
                mWriteLockHeld = null;
                notifyAll();
            }
        }

        return true;
    }
295609
void lockForHandlingWork() {
        synchronized(m_lock) {
            assert m_running == false;
            m_running = true;
            m_readyOps = 0;
            m_readyOps = m_selectionKey.readyOps();      // runnable.run() doesn't accept parameters
        }
    }
468933
def __initLock(self):
        """"""
        self._isLocked = False
        self._timer = 0
        self._operation = False
559488
private void populateLockStatus(PipelineInstanceModel instanceModel, boolean isLockable, boolean isCurrentlyLocked, boolean canBeUnlocked) {
        instanceModel.setIsLockable(isLockable);
        instanceModel.setCurrentlyLocked(isCurrentlyLocked);
        instanceModel.setCanUnlock(canBeUnlocked);
    }
144217
private Object retrieveLock(String key)
   {
      Object lock = this.lockMap.get(key);
      if(lock == null)
      {
         lock = key;
         this.lockMap.put(key, lock);
      }
      return lock;
   }
490543
def setLocked( self, state = True ):
        
        self._xLocked = state
        self._yLocked = state
824088
private boolean isLocked(String path) {

        // get lock for path
        CmsRepositoryLockInfo lock = m_session.getLock(path);
        if (lock == null) {
            return false;
        }

        // check if found lock fits to the lock token from request
        //        String currentToken = "<opaquelocktoken:" + generateLockToken(req, lock) + ">";
        //        if (currentToken.equals(parseLockTokenHeader(req))) {
        //            return false;
        //        }

        if (lock.getUsername().equals(m_username)) {
            return false;
        }

        return true;
    }
394140
def _lock(self):
        '''
        
        '''
        if not self._is_locked():
            with open(self._lck,'w') as fh:
                if self._devel: self.logger.debug("Locking")
                fh.write(str(os.getpid()))
            return True
        else:
            return False