(non-PHPdoc)
@see \oat\tao\model\lock\LockSystem::setLock()
167576
public function setLock(core_kernel_classes_Resource $resource, $ownerId)
    {
        $lock = $this->getLockData($resource);
        if (is_null($lock)) {
            $lock = new OntoLockData($resource, $ownerId, microtime(true));
            $resource->setPropertyValue($this->getLockProperty(), $lock->toJson());
        } elseif ($lock->getOwnerId() != $ownerId) {
            throw new ResourceLockedException($lock);
        }
    }
1084427
public function lock()
    {
        if ($this->status !== self::BUSY) {
            throw new \LogicException('Cannot lock a slave that is not in busy state');
        }

        $this->status = self::LOCKED;
    }
9154
public function lock(object $document, int $lockMode) : void
    {
        $id          = $this->uow->getDocumentIdentifier($document);
        $criteria    = ['_id' => $this->class->getDatabaseIdentifierValue($id)];
        $lockMapping = $this->class->fieldMappings[$this->class->lockField];
        assert($this->collection instanceof Collection);
        $this->collection->updateOne($criteria, ['$set' => [$lockMapping['name'] => $lockMode]]);
        $this->class->reflFields[$this->class->lockField]->setValue($document, $lockMode);
    }
599032
public function lock() {
		$this->_locked = true;
		
		foreach ($this->_data as $part) {
			if ($part instanceof Config) {
				$part->lock();
			}
		}
		
		return $this;
	}
158994
public function set_locked(bool $locked) {
        global $DB;

        if ($this->_locked == $locked) {
            return $this;
        }

        $this->_locked = $locked;
        $DB->set_field('context', 'locked', (int) $locked, ['id' => $this->id]);
        $this->mark_dirty();
        self::reset_caches();

        return $this;
    }
1037541
public function set($key, $value, $expire = 0)
    {
        $value = '<?php exit;?>' . time() . "($expire)" . serialize($value);

        if ($this->lock) {//自增自减
            fseek($this->lock, 0);
            $return = fwrite($this->lock, $value);
            flock($this->lock, LOCK_UN);
            fclose($this->lock);
            $this->lock = false;
        } else {
            $fileName = $this->getFileName($key);
            $return = file_put_contents($fileName, $value, LOCK_EX);
        }
        $return && clearstatcache();
        return $return;
    }
918675
function RowLock($tables,$where,$col=false)
	{
		if ($this->autoCommit) {
			$this->BeginTrans();
		}
		$this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
		return 1;
	}
1106730
protected function waitUnlock($key) 
    {
        if ($this->isLocked($key)) {
            $count = 0;
            do {
                usleep(100);
                $count ++;
            } while ($count < 10 && $this->isLocked($key));  // 最多做10次睡眠等待解锁，超时则跳过并解锁
        
            $this->isLocked($key) && $this->unlock($key);        
        }
        
        return $this;
    }
564295
protected function storeLock(Lock $lock) {
    if ($lock->getType() == Lock::TYPE_PESSIMISTIC) {
      // pessimistic locks must be stored in the database in order
      // to be seen by other users
      $lockObj = $this->persistenceFacade->create($this->lockType, BuildDepth::REQUIRED);
      $lockObj->setValue('objectid', $lock->getObjectId());
      $lockObj->setValue('login', $lock->getLogin());
      $lockObj->setValue('created', $lock->getCreated());
      // save lock immediatly
      $lockObj->getMapper()->save($lockObj);
    }
    // store the lock in the session for faster retrieval
    $this->addSessionLock($lock);
  }
468917
public function release_lock(lock $lock) {
        $params = array('locktype' => $this->dblockid,
                        'token' => $lock->get_key());
        $result = $this->db->get_record_sql('SELECT pg_advisory_unlock(:locktype, :token) AS unlocked', $params);
        $result = $result->unlocked === 't';
        if ($result) {
            unset($this->openlocks[$lock->get_key()]);
        }
        return $result;
    }
251623
public void setLocked(boolean locked) {
		if (ap == null) {
			return;
		}
		ap.setLocked(locked);
		btnPin.setVisible(! locked);
		if (!ap.isPinned()) {
			// Wont be visible if its pinned
			btnClose.setVisible(! locked);
		}
	}
905075
public function set($name, $value)
    {
        $this->instance->unlock();
        $result = $this->instance->set($name, $value);
        $this->instance->lock();

        return $result;
    }
743923
public function setLock(CacheKey $key, Lock $lock)
    {
        $this->locks[$key->hash] = $lock;
    }
1081631
public function setLockMode($lockMode)
    {
        if (in_array($lockMode, array(LockMode::NONE, LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE), true)) {
            if ( ! $this->_em->getConnection()->isTransactionActive()) {
                throw TransactionRequiredException::transactionRequired();
            }
        }

        $this->setHint(self::HINT_LOCK_MODE, $lockMode);

        return $this;
    }
1267844
protected function _lock($object, $lock)
    {
        if ($lock) {
            self::$_locks[$object->getHandle()] = true;
        } else {
            unset(self::$_locks[$object->getHandle()]);
        }
    }
1009401
public function set($key, $value)
    {
        $cont = clone $this;
        $cont->doSet($key, $this->recursiveClone($value));

        return $cont;
    }
370251
public final function lock($con) {
        if (!$con) {
            throw_exception(__('no lock condition'));
        }

        if ($con && !is_array($con)) {
            $con = [$this->primaryKeys[0] => $con];
        }

        $query = $this->select('*')->where($con);

        return new TableLocker($query);
    }