arlut.csd.ganymede
Class DBWriteLock
java.lang.Object
|
+--arlut.csd.ganymede.DBLock
|
+--arlut.csd.ganymede.DBWriteLock
- public class DBWriteLock
- extends DBLock
A DBWriteLock is a DBLock subclass
used to lock one or more
DBObjectBases for the purposes
of committing changes into those bases, preventing any
other threads from reading or writing to the database while the update
is being performed. When a DBWriteLock
is established on a DBObjectBase, the establishing thread suspends until
all readers currently working in the specified DBObjectBases complete. The
write lock is then established, and the thread possessing the DBWriteLock
is free to replace objects in the DBStore
with modified copies.
DBWriteLocks are typically created and managed by the code in the
DBEditSet
class. It is very important that any thread that obtains a DBWriteLock be
scrupulous about releasing the lock in a timely fashion once the
appropriate changes are made in the database.
- See Also:
DBEditSet,
DBObjectBase
|
Field Summary |
(package private) static boolean |
debug
|
|
Constructor Summary |
DBWriteLock(DBStore store)
constructor to get a write lock on all the object bases |
DBWriteLock(DBStore store,
java.util.Vector baseSet)
constructor to get a write lock on a subset of the
object bases. |
|
Method Summary |
void |
abort()
Withdraw this lock. |
void |
establish(java.lang.Object key)
Establish a dump lock on bases specified in this DBWriteLock's
constructor. |
void |
release()
Release this lock on all bases locked |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait |
debug
static final boolean debug
DBWriteLock
public DBWriteLock(DBStore store)
- constructor to get a write lock on all the object bases
DBWriteLock
public DBWriteLock(DBStore store,
java.util.Vector baseSet)
- constructor to get a write lock on a subset of the
object bases.
establish
public void establish(java.lang.Object key)
throws java.lang.InterruptedException
Establish a dump lock on bases specified in this DBWriteLock's
constructor. Can throw InterruptedException if another thread
orders us to abort() while we're waiting for permission to
proceed with writes on the specified baseset.
- Overrides:
establish in class DBLock
release
public void release()
- Release this lock on all bases locked
- Overrides:
release in class DBLock
abort
public void abort()
Withdraw this lock. This method can be called by a thread to
interrupt a lock establish that is blocked waiting to get
access to the appropriate set of
DBObjectBase objects. If
this method is called while another thread is blocked in
establish(), establish() will throw an InterruptedException.
Once abort() is processed, this lock may never be established.
Any subsequent calls to estabish() will always throw
InterruptedException.
- Overrides:
abort in class DBLock