org.apache.lucene.store
Class Lock
java.lang.Object
org.apache.lucene.store.Lock
public abstract class Lock
extends java.lang.Object
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();
$Id: Lock.java,v 1.12 2004/05/11 17:43:28 cutting Exp $static class | Lock.With - Utility class for executing code with exclusive access.
|
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.
|
LOCK_POLL_INTERVAL
public static long LOCK_POLL_INTERVAL
isLocked
public abstract boolean isLocked()
Returns true if the resource is currently locked. Note that one must
still call
obtain()
before using the resource.
obtain
public abstract boolean obtain()
throws IOException
Attempts to obtain exclusive access and immediately return
upon success or failure.
- true iff exclusive access is obtained
obtain
public boolean obtain(long lockWaitTimeout)
throws IOException
Attempts to obtain an exclusive lock within amount
of time given. Currently polls once per second until
lockWaitTimeout is passed.
lockWaitTimeout
- length of time to wait in ms
- true if lock was obtained
release
public abstract void release()
Releases exclusive access.
Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.