FileLock
classin packageklyn.io
public class FileLock implements AutoClosable
FileLock
All Implemented Interfaces: AutoClosable

Exclusive cooperative interprocess lock on a dedicated lock file. Acquisition waits for the previous holder; the OS releases the lock if the process exits. All writers must use the same lock path. Never delete or replace that file.

try guard = FileLock(Path("settings.lock")):
    Files.writeTextAtomic(Path("settings.json"), "{}")
Constructors
Modifier and Type Member Description
public FileLock
FileLock(path as Path)
Acquires the lock, creating its file if necessary.
Methods
Modifier and Type Member Description
public close
close() as Void
Releases this lock; repeated calls are harmless.
Inherited Methods
methodInherited Methods from AutoClosable: close