Acquires current action lock.
@return boolean lock acquiring result.
481003
protected function acquireMutex()
    {
        $this->mutex = Instance::ensure($this->mutex, Mutex::className());
        return $this->mutex->acquire($this->composeMutexName());
    }
1110290
def acquire_lock
      return true if @lock_handle
      begin
        @lock_handle = File.open(lock_file_path, File::RDWR | File::CREAT)
        raise StandardError.new('Already locked') unless @lock_handle.flock(File::LOCK_EX | File::LOCK_NB)
        @lock_handle.rewind
        @lock_handle.truncate 0
        @stat_handle = File.open(status_file_path, File::RDWR | File::CREAT)
        raise StandardError.new('Failed to open status') unless @stat_handle
        @stat_handle.rewind
        @stat_handle.truncate 0
      rescue
        if @stat_handle
          @stat_handle.close rescue nil
        end
        if @lock_handle
          @lock_handle.flock(File::LOCK_UN) rescue nil
          @lock_handle.close rescue nil
        end
        @stat_handle = nil
        @lock_handle = nil
      end
      !!@lock_handle
    end
486293
public function unlock()
    {
        $this->shouldLock = false;

        if (!$handle = $this->resource()) {
            return false;
        }

        return $this->applyLock($handle);
    }
409994
public function acquire()
    {
        if (!$this->locked) {
            $this->fp = @fopen($this->filePath, 'a');

            if (!$this->fp || !flock($this->fp, LOCK_EX | LOCK_NB)) {
                throw new LockException("Could not get lock on {$this->filePath}");
            } else {
                $this->locked = true;
            }
        }

        return $this;
    }
645744
public function read_lockfile() {
		$retval = null;
		if($this->is_lockfile_present()) {
			$retval = file_get_contents($this->get_lockfile());
		}
		else {
			throw new \Exception(__METHOD__ .": no lockfile exists");
		}
		return($retval);
	}
813345
private function lock(){
		$lockfilepath = $this->path_lockfile;
		$timeout_limit = 5;

		if( !@is_dir( dirname( $lockfilepath ) ) ){
			$this->px->fs()->mkdir_r( dirname( $lockfilepath ) );
		}

		#	PHPのFileStatusCacheをクリア
		clearstatcache();

		$i = 0;
		while( $this->is_locked() ){
			$i ++;
			if( $i >= $timeout_limit ){
				return false;
				break;
			}
			sleep(1);

			#	PHPのFileStatusCacheをクリア
			clearstatcache();
		}
		$src = '';
		$src .= 'ProcessID='.getmypid()."\r\n";
		$src .= @date( 'Y-m-d H:i:s' , time() )."\r\n";
		$RTN = $this->px->fs()->save_file( $lockfilepath , $src );
		return	$RTN;
	}
687353
public function unLock()
    {
        if (is_resource($this->handle)) {
            fflush($this->handle);
            flock($this->handle, LOCK_UN);
            fclose($this->handle);
        }

        $this->lockAcquired = false;
        $this->handle       = null;

        return $this;
    }
437310
private static function lock()
	{
		if (self::$currentlylocked === false) {
			self::$authFileP = fopen( self::$authFile , "a+" );
			if ( flock( self::$authFileP , LOCK_EX ) ) {
				self::$currentlylocked = true;
			} else {
				throw new Exception( 'Unable to lock file' );
			}
		}

		return true;
	}
1294289
public function release(): bool
    {
        if (!is_resource($this->lock)) {
            return true;
        }

        return flock($this->lock, LOCK_UN);
    }
405758
public function acquireLock($name, $timeout = null)
    {
        $blocking = $timeout === null;
        $start = microtime(true);
        $end = $start + $timeout / 1000;
        $locked = false;
        while (!(empty($this->locks[$name]) && $locked = $this->getLock($name, $blocking)) && ($blocking || ($timeout > 0 && microtime(true) < $end))) {
            usleep(static::USLEEP_TIME);
        }

        if ($locked) {
            $this->locks[$name] = true;

            return true;
        }

        return false;
    }
64221
public function unlock(): bool
    {
        $result = false;

        if ($this->locker->releaseLock()) {
            $result = true;
        }

        return $result;
    }
36292
public function isLockable()
    {
        $controller = $this->getMixer();

        if($controller instanceof ControllerModellable)
        {
            if($this->getModel()->getState()->isUnique())
            {
                $entity = $this->getModel()->fetch();

                if($entity->isLockable()) {
                    return true;
                }
            }
        }

        return false;
    }
1126197
public function getLocked()
    {
        return !$this->entity->getType()
            || SystemCollectionManagerInterface::COLLECTION_TYPE === $this->entity->getType()->getKey();
    }
1035065
protected function lockPage()
	{
		$this->isPostRequest();

		$currentUser = $this->getCurrentUser();

		if (! $currentUser) {
			return null;
		}

		$localization = $this->getPageLocalization();

		$force = $this->getRequestInput()
				->filter('force', false, false, FILTER_VALIDATE_BOOLEAN);

		try {
			if ($this->checkLock(false) === null) {
				$this->createLock();
			}
		} catch (ObjectLockedException $e) {
			if (! $force) {
				return new SupraJsonResponse($this->getLocalizationEditLockData($localization));
			}
		}

		return new SupraJsonResponse();
	}
1360970
public boolean unlock() throws IOException {
		if (lock != null) {
			lock.release();
			lock = null;
			return true;
		}
		return false;
	}
181161
public function lock()
    {
        $result = null;

        $context = $this->getContext();
        $context->table = $this->getBase();

        if ($this->invokeCommand('before.lock', $context) !== false)
        {
            if ($this->isConnected()) {
                $context->result = $this->getDriver()->lock($this->getBase());
            }

            $this->invokeCommand('after.lock', $context);
        }

        return $context->result;
    }
988614
final public function invokeAction()
    {
        $time = time();
        $success = $this->doAction();
        $this->actionRequired = !$success;
        $this->lastActionSuccess = $success;
        $this->lastActionAttemptTime = $time;

        if ($success) {
            $this->lastActionSuccessTime = $time;
        } else {
            $this->lastActionFailTime = $time;
        }

        return $success;
    }