|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.latch.SharedLatchImpl
public class SharedLatchImpl
Simple thread-based non-transactional reader-writer/shared-exclusive latch. Latches provide simple exclusive or shared transient locks on objects. Latches are expected to be held for short, defined periods of time. No deadlock detection is provided so it is the caller's responsibility to sequence latch acquisition in an ordered fashion to avoid deadlocks. Nested latches for a single thread are supported, but upgrading a shared latch to an exclusive latch is not. This implementation is based on the section Reader-Writer Locks in the book Java Threads by Scott Oaks, 2nd Edition, Chapter 8. This SharedLatch implementation is only used when Java 5 ReentrantReadWriteLocks are not available.
Constructor Summary | |
---|---|
SharedLatchImpl(java.lang.String name,
EnvironmentImpl env)
Create a shared latch. |
Method Summary | |
---|---|
void |
acquireExclusive()
Acquire a latch for exclusive/write access. |
boolean |
acquireExclusiveNoWait()
Probe a latch for exclusive access, but don't block if it's not available. |
void |
acquireShared()
Acquire a latch for shared/read access. |
boolean |
isOwner()
Return true if this thread is an owner, reader, or write. |
boolean |
isWriteLockedByCurrentThread()
|
void |
release()
Release an exclusive or shared latch. |
void |
releaseIfOwner()
Release the latch. |
void |
setExclusiveOnly(boolean exclusiveOnly)
Indicate whether this latch can only be set exclusively (not shared). |
void |
setName(java.lang.String name)
Set the latch name, used for latches in objects instantiated from the log. |
boolean |
setNoteLatch(boolean noteLatch)
If noteLatch is true, then track latch usage in the latchTable. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SharedLatchImpl(java.lang.String name, EnvironmentImpl env)
Method Detail |
---|
public void setExclusiveOnly(boolean exclusiveOnly)
setExclusiveOnly
in interface SharedLatch
public void setName(java.lang.String name)
setName
in interface SharedLatch
public boolean setNoteLatch(boolean noteLatch)
setNoteLatch
in interface SharedLatch
public void acquireExclusive() throws DatabaseException
acquireExclusive
in interface SharedLatch
LatchException
- if the latch is already held by the current
thread for shared access.
RunRecoveryException
- if an InterruptedException exception
occurs.
DatabaseException
public boolean acquireExclusiveNoWait() throws DatabaseException
SharedLatch
acquireExclusiveNoWait
in interface SharedLatch
LatchException
- if the latch is already held by the calling
thread.
DatabaseException
public void acquireShared() throws DatabaseException
acquireShared
in interface SharedLatch
RunRecoveryException
- if an InterruptedException exception
occurs.
DatabaseException
public boolean isOwner()
SharedLatch
isOwner
in interface SharedLatch
public void release() throws LatchNotHeldException
release
in interface SharedLatch
LatchNotHeldException
public void releaseIfOwner() throws LatchNotHeldException
SharedLatch
releaseIfOwner
in interface SharedLatch
LatchNotHeldException
public boolean isWriteLockedByCurrentThread()
isWriteLockedByCurrentThread
in interface SharedLatch
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |