Call with pathEntries lock taken
433585
private void getAllDependents(Set<PathEntry> result, String name) {
        Set<String> depNames = dependenctRelativePaths.get(name);
        if (depNames == null) {
            return;
        }
        for (String dep : depNames) {
            PathEntry entry = pathEntries.get(dep);
            if (entry != null) {
                result.add(entry);
                getAllDependents(result, dep);
            }
        }
    }
1019889
public void lock()
    {
        log.info("Elasticsearch has started and the maven process has been blocked. Press CTRL+C to stop the process.");

        synchronized (lock)
        {
            try
            {
                lock.wait();
            }
            catch (InterruptedException exception)
            {
                log.warn("RunElasticsearchNodeMojo interrupted");
            }
        }
    }
1286009
public void checkLock(Session session, String path, List<String> tokens) throws LockException
   {
      String repoPath = session.getRepository().hashCode() + "/" + session.getWorkspace().getName() + "/" + path;

      String currentToken = nullResourceLocks.get(repoPath);

      if (currentToken == null)
      {
         return;
      }

      if (tokens != null)
      {
         for (String token : tokens)
         {
            if (token.equals(currentToken))
            {
               return;
            }
         }
      }

      throw new LockException("Resource already locked " + repoPath);
   }
1263476
function unlock(to) {
  to = fis.file.wrap(to).realpath;
  delete lockedMap[to];
}
394595
private function _checkCurrentLocks()
    {
        foreach ($this->_classHierarchy as $classInfo) {
            // FATAL: If any part of our class hierarchy is already locked ("is
            // being compiled right now", higher up the call stack), then it's a
            // bad map with circular "import"-statements.
            // NOTE: This specifically protects against the dangerous scenario
            // of importing classes derived from our hierarchy but whose
            // classname isn't in the current class hierarchy, so they weren't
            // blocked by the "import-target sanity checks". So when they get
            // to their own sub-compilation, their class hierarchy is checked
            // here and we'll discover their circular inheritance.
            if (isset($this->_propertyMapCache->compilerLocks[$classInfo['className']])) {
                // NOTE: strictClassName goes in "arg1" because it's being
                // compiled earlier than us, so we're definitely the "arg2".
                throw new CircularPropertyMapException(
                    $classInfo['strictClassName'],
                    $this->_strictSolveClassName
                );
            }
        }
    }
46346
def Unlock(fd, path):
  
  try:
    fcntl.flock(fd, fcntl.LOCK_UN | fcntl.LOCK_NB)
  except IOError as e:
    if e.errno == errno.EWOULDBLOCK:
      raise IOError('Exception unlocking %s. Locked by another process.' % path)
    else:
      raise IOError('Exception unlocking %s. %s.' % (path, str(e)))
200168
public void queueEntry(String entryPath, InputStream inStream,
                           int maxBytes)
                           throws IOException, TarMalformatException {
        entryQueue.add(new TarEntrySupplicant(entryPath, inStream, maxBytes,
                                              '0', archive));
    }
790133
function notifyWatchersOnPaths(paths) {
    var expandedPaths = _expandNestedPaths(paths);

    watchers.map(function _notifyWatcher(watcher) {
      var hasPath = intersect(expandedPaths, watcher.paths).length > 0;

      if (hasPath) {
        var watchedKeyValues = {};
        try {
          watchedKeyValues = getAll(paths);
        } catch (e) {}

        if (watcher.options.async !== false) {
          setTimeout(function () {
            watcher.callback(watchedKeyValues);
          }, watcher.options.async || 0);
        } else {
          watcher.callback(watchedKeyValues);
        }
      }
    });

    if (paths !== '*') {
      notifyGlobalWatchers();
    }
  }
628835
private void lockResource(CmsObject cms, CmsLock lock, CmsResource res) throws CmsException {

        if (lock.isNullLock()) {
            cms.lockResource(res.getRootPath());
        }
    }
22282
public static DirLock tryLock(FileSystem fs, Path dir) throws IOException {
    Path lockFile = getDirLockFile(dir);

    try {
      FSDataOutputStream ostream = HdfsUtils.tryCreateFile(fs, lockFile);
      if (ostream!=null) {
        LOG.debug("Thread ({}) Acquired lock on dir {}", threadInfo(), dir);
        ostream.close();
        return new DirLock(fs, lockFile);
      } else {
        LOG.debug("Thread ({}) cannot lock dir {} as its already locked.", threadInfo(), dir);
        return null;
      }
    } catch (IOException e) {
        LOG.error("Error when acquiring lock on dir " + dir, e);
        throw e;
    }
  }
103877
final void cmdRemoveExpiring(final long lockId, final PersistentTransaction transaction) throws ProtocolException, TransactionException, SevereMessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "cmdRemoveExpiring", new Object[] { "Item Link:   " + this, "Stream Link: " + _owningStreamLink, formatLockId(lockId),
                                                                     "Transaction: " + transaction });

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            SibTr.debug(this, tc, "expiring item " + _tuple.getUniqueId());

        synchronized (this)
        {
            if (ItemLinkState.STATE_LOCKED_FOR_EXPIRY == _itemLinkState)
            {
                if (_lockID != lockId)
                {
                    throw new LockIdMismatch(_lockID, lockId);
                }

                ListStatistics stats = getParentStatistics();
                synchronized (stats)
                {
                    stats.decrementExpiring();
                    stats.incrementRemoving();
                }

                _transactionId = transaction.getPersistentTranId();
                _itemLinkState = ItemLinkState.STATE_REMOVING_EXPIRING;
            }
            else
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                    SibTr.event(this, tc, "Invalid Item state: " + _itemLinkState);
                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(this, tc, "cmdRemoveExpiring");
                throw new StateException(_itemLinkState.toString());
            }
        }
        final Task task = new RemoveLockedTask(this);
        transaction.addWork(task);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "cmdRemoveExpiring");
    }
999204
private LockedObject generateLockedObjects( String path ) {
        if (!locks.containsKey(path)) {
            LockedObject returnObject = new LockedObject(this, path, !temporary);
            String parentPath = getParentPath(path);
            if (parentPath != null) {
                LockedObject parentLockedObject = generateLockedObjects(parentPath);
                parentLockedObject.addChild(returnObject);
                returnObject.parent = parentLockedObject;
            }
            return returnObject;
        }
        // there is already a LockedObject on the specified path
        return this.locks.get(path);
    }
409069
protected function pathIsLocked($path, $lockMode = null, $openMode = 'r+')
    {
        $lockTestResource = fopen($path, $openMode);
        $lockMode = $lockMode ?: $this->getLockMode() | LOCK_NB;

        if (!flock($lockTestResource, $lockMode)) {
            return true;
        }

        // Remove my created lock.
        flock($lockTestResource, LOCK_UN);

        return false;

    }
855314
protected synchronized void applyEntries(boolean blocking) throws IOException {
    if (blocking) { /* Blocking Mode */
      synchronized(_entryApply) {
        List<Entry<V>> entryList = new ArrayList<Entry<V>>();
        while(_entryPool.getServiceQueueSize() > 0) {
          Entry<V> entry = _entryPool.pollFromService();
          if(entry != null) entryList.add(entry);
        }
        
        applyEntries(entryList);
      }
    } else {        /* Non-Blocking Mode */
      synchronized(_entryApply) {
        for(int i = 0; i < _maxEntries; i++) {
          Entry<V> entry = _entryPool.pollFromService();
          if(entry != null) _entryApply.add(entry);
        }
      }
      
      // Start a separate thread to update the underlying array file 
      new Thread(_entryApply).start();
    }
  }
263516
public static FileLock tryLock(FileSystem fs, Path fileToLock, Path lockDirPath, String spoutId)
          throws IOException {
    Path lockFile = new Path(lockDirPath, fileToLock.getName());

    try {
      FSDataOutputStream ostream = HdfsUtils.tryCreateFile(fs, lockFile);
      if (ostream != null) {
        LOG.debug("Acquired lock on file {}. LockFile= {}, Spout = {}", fileToLock, lockFile, spoutId);
        return new FileLock(fs, lockFile, ostream, spoutId);
      } else {
        LOG.debug("Cannot lock file {} as its already locked. Spout = {}", fileToLock, spoutId);
        return null;
      }
    } catch (IOException e) {
      LOG.error("Error when acquiring lock on file " + fileToLock + " Spout = " + spoutId, e);
      throw e;
    }
  }
47725
function isTaskLocked(task) {
  if(task.semaphore) {
    if(!task.semaphore.ttl) {
      throw new TypeError('TimeToLiveNotPresent');
    }
    return ( (timestamp() - task.semaphore.time) < task.semaphore.ttl );
  }
  return false;
}
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;
    }