મુખ્ય સામગ્રીને બાયપાસ કરો

FileLock

A FileLock instance encapsulates a native whole-file lock and file locking between php-wasm processes.

A FileLock supports php-wasm whole-file locks and byte range locks. Before granting a php-wasm lock, a FileLock ensures that it first holds a compatible native lock. If a compatible native lock cannot be acquired, the php-wasm lock is not granted.

Index

Constructors

constructor

Methods

findFirstConflictingByteRangeLock

  • findFirstConflictingByteRangeLock(desiredLock: Omit<RequestedRangeLock, fd>): LockedRange | { end: bigint; pid: number; start: bigint; type: shared | exclusive }
  • Find the first conflicting byte range lock.

    This method corresponds to the fcntl() F_GETLK command.


    Parameters

    Returns LockedRange | { end: bigint; pid: number; start: bigint; type: shared | exclusive }

    The first conflicting byte range lock, or undefined if no conflicting lock exists.

isUnlocked

  • isUnlocked(): boolean
  • Check if the file lock is unlocked.


    Returns boolean

    True if the file lock is unlocked, false otherwise.

lockFileByteRange

  • Lock a byte range.

    This method corresponds to the fcntl() F_SETLK command.


    Parameters

    Returns boolean

    True if the lock was granted, false otherwise.

lockWholeFile

  • Lock the whole file.

    This method corresponds to the flock() function.


    Parameters

    • op: Omit<WholeFileLockOp, waitForLock>

      The whole file lock operation to perform.

    Returns boolean

    True if the lock was granted, false otherwise.

releaseLocksForProcess

  • releaseLocksForProcess(pid: number): void
  • Release all locks for the given process.


    Parameters

    • pid: number

      The process ID to release locks for.

    Returns void

releaseLocksOnFdClose

  • releaseLocksOnFdClose(pid: number, fd: number): void
  • Release all locks for the given process and file descriptor.


    Parameters

    • pid: number

      The process ID to release locks for.

    • fd: number

      The file descriptor to release locks for.

    Returns void