Convert a Lock identifier into an actual Lock instance.
        @param lockid: a locks.MasterLock or locks.WorkerLock instance
        @return: a locks.RealMasterLock or locks.RealWorkerLock instance
347870
def getLockByID(self, lockid):
        
        assert isinstance(lockid, (locks.MasterLock, locks.WorkerLock))
        if lockid not in self.locks:
            self.locks[lockid] = lockid.lockClass(lockid)
        # if the master.cfg file has changed maxCount= on the lock, the next
        # time a build is started, they'll get a new RealLock instance. Note
        # that this requires that MasterLock and WorkerLock (marker) instances
        # be hashable and that they should compare properly.
        return self.locks[lockid]
257799
static int computeLockId(String s) {
        // This method handles the following fact: Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE
        int hashCode = s.hashCode();
        if (hashCode == Integer.MIN_VALUE) {
            hashCode = 13;
        }
        return Math.abs(hashCode) % 1073741823;
    }
204171
public final Lock lock(Object key) {
        Lock lock = this.locks.get(key);
        lock.lock();
        return lock;
    }
537435
public ClientBuilderForConnector withCredentialsId(String credentialsId)
            throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
        if (isNotBlank(credentialsId)) {
            withCredentials(lookupSystemCredentials(credentialsId));
        } else {
            withSslConfig(null);
        }

        return this;
    }
442453
public IEntityLock newWriteLock(EntityIdentifier entityID, String owner)
            throws LockingException {
        return lockService.newLock(
                entityID.getType(), entityID.getKey(), IEntityLockService.WRITE_LOCK, owner);
    }
718169
public synchronized Long generateId() {
        if (sequenceBlock == null || !sequenceBlock.hasNext()) {
            sequenceBlock = allocateSequenceBlock();
        }
        return sequenceBlock.next();
    }
1266977
def lock_id(locker_uid, id_to_lock, expire_in_sec = 5)
      now = redis_time
      @con.multi do
        @con.zadd("#{LOCK_MAP_KEY}_z", (now + expire_in_sec), id_to_lock)
        @con.hset("#{LOCK_MAP_KEY}_h", id_to_lock, locker_uid)
      end
    end
1102573
public static synchronized MCAAuthorizationManager createInstance(Context context, String tenantId) {
        instance = createInstance(context);
        if (null != tenantId) {
            instance.tenantId = tenantId;
        }
        return instance;

    }
666917
public OJBLock createIsolationLevel(Object resourceId, Object isolationId, LoggerFacade logger)
    {
        OJBLock result = null;
        switch(((Integer) isolationId).intValue())
        {
            case LockManager.IL_READ_UNCOMMITTED:
                result = new ReadUncommittedLock(resourceId, logger);
                break;
            case LockManager.IL_READ_COMMITTED:
                result = new ReadCommitedLock(resourceId, logger);
                break;
            case LockManager.IL_REPEATABLE_READ:
                result = new RepeadableReadsLock(resourceId, logger);
                break;
            case LockManager.IL_SERIALIZABLE:
                result = new SerializeableLock(resourceId, logger);
                break;
            case LockManager.IL_OPTIMISTIC:
                throw new LockRuntimeException("Optimistic locking must be handled on top of this class");
            default:
                throw new LockRuntimeException("Unknown lock isolation level specified");
        }
        return result;
    }
652513
public LockedInodePath lockFullInodePath(long id, LockPattern lockPattern)
      throws FileDoesNotExistException {
    LockedInodePath inodePath = lockInodePathById(id, lockPattern);
    if (!inodePath.fullPathExists()) {
      inodePath.close();
      throw new FileDoesNotExistException(ExceptionMessage.INODE_DOES_NOT_EXIST.getMessage(id));
    }
    return inodePath;
  }
559609
public String queryLock (NodeObject.Lock lock)
    {
        for (NodeObject nodeobj : getNodeObjects()) {
            if (nodeobj.locks.contains(lock)) {
                return nodeobj.nodeName;
            }
        }
        return null;
    }
585080
@Override
    public LockResult lock(int waitWeight, String clientId) {
        return lock(waitWeight, clientId, DEFAULT_LOCK_DURATION_MS);
    }
392469
public IEntityLock newReadLock(EntityIdentifier entityID, String owner)
            throws LockingException {
        return lockService.newLock(
                entityID.getType(), entityID.getKey(), IEntityLockService.READ_LOCK, owner);
    }
229220
public Observable<ServiceResponse<ManagementLockObjectInner>> getAtSubscriptionLevelWithServiceResponseAsync(String lockName) {
        if (lockName == null) {
            throw new IllegalArgumentException("Parameter lockName is required and cannot be null.");
        }
        if (this.client.subscriptionId() == null) {
            throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
        }
        if (this.client.apiVersion() == null) {
            throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
        }
        return service.getAtSubscriptionLevel(lockName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent())
            .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<ManagementLockObjectInner>>>() {
                @Override
                public Observable<ServiceResponse<ManagementLockObjectInner>> call(Response<ResponseBody> response) {
                    try {
                        ServiceResponse<ManagementLockObjectInner> clientResponse = getAtSubscriptionLevelDelegate(response);
                        return Observable.just(clientResponse);
                    } catch (Throwable t) {
                        return Observable.error(t);
                    }
                }
            });
    }
812232
public boolean unlockBlock(long sessionId, long blockId) {
    synchronized (mSharedMapsLock) {
      Set<Long> sessionLockIds = mSessionIdToLockIdsMap.get(sessionId);
      if (sessionLockIds == null) {
        return false;
      }
      for (long lockId : sessionLockIds) {
        LockRecord record = mLockIdToRecordMap.get(lockId);
        if (record == null) {
          // TODO(peis): Should this be a check failure?
          return false;
        }
        if (blockId == record.getBlockId()) {
          mLockIdToRecordMap.remove(lockId);
          sessionLockIds.remove(lockId);
          if (sessionLockIds.isEmpty()) {
            mSessionIdToLockIdsMap.remove(sessionId);
          }
          Lock lock = record.getLock();
          unlock(lock, blockId);
          return true;
        }
      }
      return false;
    }
  }
831742
public boolean acquire(final Lock lock) {
        lock.setUniqueId(this.uniqueId);
        if (this.lockTimeout > 0) {
            lock.setExpirationDate(ZonedDateTime.now(ZoneOffset.UTC).plusSeconds(this.lockTimeout));
        } else {
            lock.setExpirationDate(null);
        }
        var success = false;
        try {
            if (lock.getApplicationId() != null) {
                this.entityManager.merge(lock);
            } else {
                lock.setApplicationId(this.applicationId);
                this.entityManager.persist(lock);
            }
            success = true;
        } catch (final Exception e) {
            success = false;
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("[{}] could not obtain [{}] lock.", this.uniqueId, this.applicationId, e);
            } else {
                LOGGER.info("[{}] could not obtain [{}] lock.", this.uniqueId, this.applicationId);
            }
        }
        return success;
    }
1007059
def get_lock (name, debug=False):
    
    lock = threading.Lock()
    # for thread debugging, use the DebugLock wrapper
    if debug:
        lock = DebugLock(lock, name)
    return lock