Class Lock
An interprocess mutex lock.
Typical use might look like:
new Lock.With(directory.makeLock("my.lock")) {
public Object doBody() {
... code to execute while locked ...
}
}.run();
Inheritance
System.Object
Lock
Namespace:
Assembly: Lucene.Net.NetCore.dll
Syntax
public abstract class Lock : object
Fields
Name | Description |
---|---|
failureReason | If a lock obtain called, this failureReason may be set with the "root cause" Exception as to why the lock was not obtained. |
LOCK_OBTAIN_WAIT_FOREVER | Pass this value to Obtain(Int64) to try forever to obtain the lock. |
LOCK_POLL_INTERVAL | How long Obtain(Int64) waits, in milliseconds, in between attempts to acquire the lock. |
Methods
Name | Description |
---|---|
IsLocked() | Returns true if the resource is currently locked. Note that one must still call Obtain() before using the resource. |
Obtain() | Attempts to obtain exclusive access and immediately return upon success or failure. |
Obtain(Int64) | Attempts to obtain an exclusive lock within amount of time given. Polls once per LOCK_POLL_INTERVAL (currently 1000) milliseconds until lockWaitTimeout is passed. |
Release() | Releases exclusive access. |