Lock.

@return void
423805
protected static function lock()
    {
        $fd = fopen(static::$_startFile, 'r');
        if (!$fd || !flock($fd, LOCK_EX)) {
            static::log("Workerman[".static::$_startFile."] already running");
            exit;
        }
    }
87761
public void lock() {
		if (cancel != null)
			return;
		if (error != null)
			return;
		Thread t;
		BlockedThreadHandler blockedHandler;
		do {
			synchronized (this) {
				if (!locked) {
					locked = true;
					return;
				}
				t = Thread.currentThread();
				blockedHandler = Threading.getBlockedThreadHandler(t);
				if (blockedHandler != null) break;
				try { this.wait(0); }
				catch (InterruptedException e) { continue; }
			}
		} while (true);
		blockedHandler.blocked(this, 0);
	}
1318953
public function lock()
    {
        $user = UserHelper::getUser($this->getUserResource());

        if ($this->getUserLocksService()->lockUser($user)) {
            $this->returnJson(['success' => true, 'message' => __('User %s successfully locked', UserHelper::getUserLogin(UserHelper::getUser($user)))]);
        } else {
            $this->returnJson(['success' => false, 'message' => __('User %s can not be locked', UserHelper::getUserLogin(UserHelper::getUser($user)))]);
        }
    }
507460
protected function lock_process() {
		Logger::info( "Locking process {$this->identifier}");
		$this->start_time = time(); // Set start time of current process.

		$lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute
		$lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );

		update_option($this->identifier . '_process_lock', ['time' => microtime(), 'expires' => time() + $lock_duration]);
	}
1339918
public function release()
    {
        if ($this->locked) {
            flock($this->fp, LOCK_UN);
            fclose($this->fp);

            $this->fp = null;
            $this->locked = false;
        }

        return $this;
    }
430881
public function unlock()
    {
        $this->storage->openWriter();
        $object = $this->getObjectSafely('openWriter');
        $object->setLocked(false);
        $this->lock = false;
        $this->storage->setObject($object);
        $this->storage->close();
        return $this;
    }
501622
public function unlock()
    {
        $dir = $this->getDir();

        if ($this->filesystem->exists($dir . '.lock')) {
            $this->filesystem->remove($dir . '.lock');
        }
    }
980427
public function lock()
    {
        //Prevent lock take over, only an saved and unlocked row and be locked
        if(!$this->isNew() && !$this->isLocked())
        {
            $this->locked_by = (int) $this->getObject('user')->getId();
            $this->locked_on = gmdate('Y-m-d H:i:s');
            $this->save();
        }

        return true;
    }
989328
public static function release()
	{
		if ( is_null( self::$authFileP ) ) return;
		$a = @flock( self::$authFileP , LOCK_UN );
		@fclose( self::$authFileP );
		self::$authFileP       = null;
		self::$currentlylocked = false;
	}
1190387
public function lock()
    {
        if ($this->fp === null) {
            $this->fp = fopen($this->file, 'r');
        }

        return flock($this->fp, LOCK_EX);
    }
1356316
public function lock($lockName)
    {
        $lockHandle = $this->lockProvider->lock($lockName);

        if ($lockHandle === false) {
            return false;
        }

        $this->lockList[$lockName] = $lockHandle;
        return true;
    }
469735
public function release() {
        if (!$this->releaser) {
            return;
        }

        // Invoke the releaser function given to us by the synchronization source
        // to release the lock.
        $releaser = $this->releaser;
        $this->releaser = null;
        ($releaser)($this);
    }
165866
public void lock() {
		if (cancel != null)
			return;
		if (error != null)
			return;
		Thread t = Thread.currentThread();
		if (t == lockingThread) {
			lockedTimes++;
			return;
		}
		BlockedThreadHandler blockedHandler = null;
		do {
			synchronized (this) {
				if (lockingThread == null) {
					lockingThread = t;
					lockedTimes = 1;
					return;
				}
				if (blockedHandler == null)
					blockedHandler = Threading.getBlockedThreadHandler(t);
				if (blockedHandler == null) {
					try { this.wait(0); }
					catch (InterruptedException e) { /* ignore */ }
					continue;
				}
			}
			blockedHandler.blocked(this, 0);
		} while (true);
	}
200454
public function unlockSite()
    {
        if (is_resource($this->lockResource)) {
            flock($this->lockResource, LOCK_UN);
            fclose($this->lockResource);
            unlink($this->lockPathAndFilename);
        }
        @unlink($this->lockFlagPathAndFilename);
    }
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;
    }
519832
function lock()
    {
        if ( $fp = $this->fp() )
        {
            if ( flock( $fp, LOCK_EX ) )
            {
                $this->clearMeta();
                $this->setMeta( 'timestamp', time() );
                return true;
            }
        }
        return false;
    }
1364986
def lock(self):
        """"""
        if not self.__lock_state:
            data = self._controller.command(self._id, 'charge_port_door_close',
                                            wake_if_asleep=True)
            if data['response']['result']:
                self.__lock_state = True
            self.__manual_update_time = time.time()