org.apache.lucene.store
public abstract class Lock extends Object
Typical use might look like:
new Lock.With(directory.makeLock("my.lock")) {
public Object doBody() {
... code to execute while locked ...
}
}.run();
Version: $Id: Lock.java 510176 2007-02-21 20:01:36Z mikemccand $
See Also: makeLock
| Nested Class Summary | |
|---|---|
| abstract static class | Lock.With Utility class for executing code with exclusive access. |
| Field Summary | |
|---|---|
| protected Throwable | failureReason
If a lock obtain called, this failureReason may be set
with the "root cause" Exception as to why the lock was
not obtained. |
| static long | LOCK_POLL_INTERVAL |
| Method Summary | |
|---|---|
| abstract boolean | isLocked() Returns true if the resource is currently locked. |
| abstract boolean | obtain() Attempts to obtain exclusive access and immediately return
upon success or failure. |
| boolean | obtain(long lockWaitTimeout) Attempts to obtain an exclusive lock within amount
of time given. |
| abstract void | release() Releases exclusive access. |
Returns: true iff exclusive access is obtained
Parameters: lockWaitTimeout length of time to wait in ms
Returns: true if lock was obtained
Throws: LockObtainFailedException if lock wait times out IOException if obtain() throws IOException