|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.io.LockFile
public class LockFile
Lock file. Implements an exclusive lock/unlock mechanism using a physical file as the underlying synchronization object.
When the lock is acquired, an attempt is made to create the lock file. Multiple attempts ate made, sleeping for a short interval (250 msec) between attempts, until the file is successfully created or the time-out interval is passed.
When the lock is released, the lock file is deleted.
Field Summary | |
---|---|
(package private) static java.lang.String |
REV
Revision information. |
Constructor Summary | |
---|---|
LockFile(java.io.File fname)
Constructor. |
Method Summary | |
---|---|
boolean |
acquire(int timeOut)
Acquire an exclusive lock with this lock file. |
boolean |
isLocked()
Determines if a lock has been acquired for this lock file. |
int |
lockCount()
Determines the number of nested locks acquired for this lock file. |
boolean |
release()
Release the exclusive lock acquired with this lock file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final java.lang.String REV
Constructor Detail |
---|
public LockFile(java.io.File fname) throws java.io.IOException
fname
- Name of the lock file.
java.io.IOException
- Thrown if fname is malformed or does not name an accessible file.Method Detail |
---|
public boolean acquire(int timeOut) throws java.io.IOException
acquire
in interface Lock
timeOut
- The maximum number of milliseconds to wait while attempting to acquire a
lock before giving up. A value of zero specifies an unlimited wait time.
Note that the resolution of the system clock may be coarser than one
millisecond, so this parameter is only an approximation of the actual
time-out interval used.
java.io.IOException
- Thrown if an I/O error occurs.public boolean release() throws java.io.IOException
release
in interface Lock
java.io.IOException
- Thrown if an I/O error occurs.public boolean isLocked()
isLocked
in interface Lock
public int lockCount()
lockCount
in interface Lock
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |