FileLease.AcquireAsync
Section titled “FileLease.AcquireAsync”
- Waits for exclusive ownership without blocking an owner thread or changing shared data.
Required contracts
Section titled “Required contracts”API: engine
Project: Inno.Core.IO
Declaration
Section titled “Declaration”public static System.Threading.Tasks.ValueTask<Inno.Core.IO.FileLease> Inno.Core.IO.FileLease.AcquireAsync(string path, System.TimeSpan timeout, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))Parameters
Section titled “Parameters”Parameter path: The absolute lease file path; all participants must use the same persistent path.
Parameter timeout: The maximum wait, or F:System.Threading.Timeout.InfiniteTimeSpan for no time limit.
Parameter cancellationToken: Cancels waiting before ownership is returned.
Returns
Section titled “Returns”The exclusive lease whose disposal permits the next participant to acquire ownership.
Remarks
Section titled “Remarks”Lease files remain after disposal. Removing them would let Unix processes lock different inodes for the same path while an earlier participant still owns the original inode.
Exceptions
Section titled “Exceptions”Exception T:System.ArgumentException: The path is empty or relative, or the timeout is negative and not infinite.
Exception T:System.TimeoutException: Another participant retains ownership beyond the permitted wait.
Exception T:System.OperationCanceledException: Waiting was canceled; no lease is returned.
Exception T:System.IO.IOException: The lease cannot be opened for a reason other than competing ownership.
Exception T:System.UnauthorizedAccessException: The operating system denies access to the lease path.