Blocking lock which returns if the lock did block.

@throws LockException
@return bool true if the lock was blocked.
486837
public function checkedLock()
    {
        $isLocked = ! flock($this->handle, LOCK_EX | LOCK_NB);
        if ($isLocked) {
            $this->lock();

        }
        return $isLocked;
    }
399670
public function acquire($blocking = true)
    {
        if ($this->locked) {
            throw new \RuntimeException('already lock by yourself');
        }

        if ($blocking === false) {
            if (version_compare(PHP_VERSION, '5.6.0') < 0) {
                throw new \RuntimeException('php version is at least 5.6.0 for param blocking');
            }
            if (!sem_acquire($this->lock_id, true)) {
                return false;
            }
            $this->locked = true;

            return true;
        }

        if (!sem_acquire($this->lock_id)) {
            return false;
        }
        $this->locked = true;

        return true;
    }
58436
public boolean hasCorrectLockstate() {

        org.opencms.lock.CmsLock lock = null;
        try {
            // get the lock state for the current resource
            lock = getCms().getLock(getParamResource());
        } catch (CmsException e) {
            // error getting lock state, log the error and return false
            LOG.error(e.getLocalizedMessage(getLocale()), e);
            return false;
        }
        // check if auto lock feature is enabled
        boolean autoLockFeature = lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources();
        return autoLockFeature || lock.isExclusive() || lock.isInherited();
    }
1358880
protected function _release_lock()
    {
        if (!$this->_lock) {
            return true;
        }
        if ($this->getConnection()->query("SELECT RELEASE_LOCK('".$this->_lock."') AS ci_session_lock")->row()->ci_session_lock) {
            $this->_lock = false;
            return true;
        }
        return false;
    }
657915
private function lock($name = null, $blocking = false)
    {
        if (!class_exists(SemaphoreStore::class)) {
            throw new LogicException('To enable the locking feature you must install the symfony/lock component.');
        }

        if (null !== $this->lock) {
            throw new LogicException('A lock is already in place.');
        }

        if (SemaphoreStore::isSupported()) {
            $store = new SemaphoreStore();
        } else {
            $store = new FlockStore();
        }

        $this->lock = (new Factory($store))->createLock($name ?: $this->getName());
        if (!$this->lock->acquire($blocking)) {
            $this->lock = null;

            return false;
        }

        return true;
    }
608735
private function acquireLock()
    {
        if (file_exists($this->lockFile)) {
            $stale_after = filemtime($this->lockFile) + $this->maxLockAge;
            if (time() > $stale_after) {
                // The lockfile is stale, delete it and reacquire a lock
                @rmdir($this->lockFile);
            } else {
                // The lockfile is valid, WURFL is probably being reloaded in another thread
                return false;
            }
        }
        
        // Using mkdir instead of touch since mkdir is atomic
        $this->isLocked = @mkdir($this->lockFile, 0775);
        return $this->isLocked;
    }
168368
public function podiumLock()
    {
        $this->locked = !$this->locked;
        if ($this->save()) {
            Log::info($this->locked ? 'Thread locked' : 'Thread unlocked', $this->id, __METHOD__);
            return true;
        }
        return false;
    }
74751
public boolean isLockLive(String nodeId) throws LockException
   {
      try
      {
         return isLockLive.run(nodeId);
      }
      catch (LockException e)
      {
         if (LOG.isTraceEnabled())
         {
            LOG.trace("An exception occurred: " + e.getMessage());
         }
      }
      return false;
   }
1099619
public boolean isBlock() throws SftpStatusException, SshException {
		// This is long hand because gcj chokes when it is not? Investigate why
		if ((getAttributes().getPermissions().longValue() & SftpFileAttributes.S_IFBLK) == SftpFileAttributes.S_IFBLK) {
			return true;
		}
		return false;
	}
142419
public function isUnlocked()
    {
        if (!is_null($this->unlockedAt)) {
            return true;
        }
        if ($this->points >= $this->details->points) {
            return true;
        }
        return false;
    }
1365689
private boolean isAllOrDirtyOptLocking() {
		EntityMetamodel entityMetamodel = getEntityMetamodel();
		return entityMetamodel.getOptimisticLockStyle() == OptimisticLockStyle.DIRTY
				|| entityMetamodel.getOptimisticLockStyle() == OptimisticLockStyle.ALL;
	}
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;
    }
  }
1360970
public boolean unlock() throws IOException {
		if (lock != null) {
			lock.release();
			lock = null;
			return true;
		}
		return false;
	}
826694
public function canAddblock()
    {
        if (!$this->actor) {
            return false;
        }

        if (!$this->getItem()) {
            return false;
        }

        if ($this->getItem()->isAdministrable() && !$this->canAdminister()) {
            return false;
        }

        return $this->actor->authorize('blocker', array('viewer' => $this->getItem()));
    }
914196
public function lock()
    {
        if (!$this->isLocked()) {
            $file = fopen($this->getFilePath(), 'w');
            if ($file) {
                fwrite($file, getmypid());
                fclose($file);
                return true;
            }
        }
        return false;
    }
228924
private boolean isLocked(Class entityType, String entityKey, Integer lockType)
            throws LockingException {
        IEntityLock[] locks = retrieveLocks(entityType, entityKey, lockType);
        return locks.length > 0;
    }
819254
public function lock () {
        if (!$this->beforeLock ()) {
            return false;
        }
        $redis = $this->getConnection ()->getClient ();
        if (!$redis->setnx ($this->name , $this->getExpiresAt (true))) {
            // see if this mutex has expired

            $value = $redis->get ($this->name);
            if ($value > microtime (true)) {
                return false;
            }
        }
        $this->afterLock ();
        return true;
    }