Class JournalFileSymlinkLock
- Namespace
- OptunaSharp.Storages.Journal
- Assembly
- OptunaSharp.dll
Lock class for synchronizing processes for NFSv2 or later.
Port of JournalFileSymlinkLock.
On acquiring the lock, a symbolic link is created for an exclusive file. The file is deleted when the lock is released. In NFS environments prior to NFSv3, use this instead of JournalFileOpenLock. On Windows without symlink privileges, use JournalFileOpenLock. Passed explicitly, this lock fails there, as Python's does; a JournalFileBackend built without a lock switches to the open-file protocol by itself.
public class JournalFileSymlinkLock : BaseJournalFileLock
- Inheritance
-
JournalFileSymlinkLock
- Inherited Members
Constructors
JournalFileSymlinkLock(string, int?)
Creates a journal lock policy with optional stale-lock recovery.
public JournalFileSymlinkLock(string filepath, int? gracePeriod = 30)
Parameters
filepathstringThe path of the file whose race condition must be protected.
gracePeriodint?Grace period before an existing lock is forcibly released.
Exceptions
- ValueError
A non-null grace period is zero or negative.
Properties
GracePeriod
Grace period before an existing lock is forcibly released.
public int? GracePeriod { get; }
Property Value
- int?
Methods
Acquire()
Acquire a lock in a blocking way by creating a symbolic link of a file.
public override bool Acquire()
Returns
- bool
True after acquiring exclusive ownership.
Exceptions
- IOException
Lock creation fails for a reason other than an existing lock.
- UnauthorizedAccessException
Lock-file or symbolic-link creation is denied.
Release()
Release a lock by removing the symbolic link.
public override void Release()
Exceptions
- RuntimeError
The lock cannot be renamed and deleted, including when ownership was lost.