FileLock
Index
Constructors
constructor
Returns FileLock
Methods
findFirstConflictingByteRangeLock
Find the first conflicting byte range lock.
This method corresponds to the fcntl() F_GETLK command.
Parameters
desiredLock: Omit<RequestedRangeLock, fd>
The desired byte range lock.
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
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
requestedLock: Omit<RequestedRangeLock, waitForLock | fd>
The byte range lock to perform.
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
Release all locks for the given process.
Parameters
pid: number
The process ID to release locks for.
Returns void
releaseLocksOnFdClose
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
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.