Class Lock.With<T>
Utility class for executing code with exclusive access.
Inherited Members
Namespace: Lucene.Net.Store
Assembly: Lucene.Net.dll
Syntax
public abstract class Lock.With<T>
Type Parameters
Name | Description |
---|---|
T |
Constructors
With(Lock, long)
Constructs an executor that will grab the named lock
.
Declaration
protected With(Lock @lock, long lockWaitTimeout)
Parameters
Type | Name | Description |
---|---|---|
Lock | lock | the Lock instance to use |
long | lockWaitTimeout | length of time to wait in milliseconds or LOCK_OBTAIN_WAIT_FOREVER to retry forever |
Methods
DoBody()
Code to execute with exclusive access.
Declaration
protected abstract T DoBody()
Returns
Type | Description |
---|---|
T |
Run()
Calls DoBody() while lock is obtained. Blocks if lock cannot be obtained immediately. Retries to obtain lock once per second until it is obtained, or until it has tried ten times. Lock is released when DoBody() exits.
Declaration
public virtual T Run()
Returns
Type | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
LockObtainFailedException | if lock could not be obtained |
IOException | if Obtain() throws IOException |