|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.latch.Latch
public class Latch
Simple thread-based non-transactional exclusive non-nestable latch.
Latches provide simple exclusive 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.
A latch can be acquire in wait or no-wait modes. In the former, the caller will wait for any conflicting holders to release the latch. In the latter, if the latch is not available, control returns to the caller immediately.
Constructor Summary | |
---|---|
Latch(EnvironmentImpl env)
Create a latch with no name, more optimal for shortlived latches. |
|
Latch(String name,
EnvironmentImpl env)
Create a latch. |
Method Summary | |
---|---|
void |
acquire()
Acquire a latch for exclusive/write access. |
boolean |
acquireNoWait()
Acquire a latch for exclusive/write access, but do not block if it's not available. |
static void |
clearNotes()
|
static int |
countLatchesHeld()
Only call under the assert system. |
static void |
dumpLatchesHeld()
|
LatchStats |
getLatchStats()
|
boolean |
isOwner()
Return true if the current thread holds this latch. |
static String |
latchesHeldToString()
|
(package private) int |
nWaiters()
Return the number of threads waiting. |
(package private) Thread |
owner()
Used only for unit tests. |
void |
release()
Release the latch. |
void |
releaseIfOwner()
Release the latch. |
void |
setName(String name)
Set the latch name, used for latches in objects instantiated from the log. |
String |
toString()
Formats a latch owner and waiters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Latch(String name, EnvironmentImpl env)
public Latch(EnvironmentImpl env)
Method Detail |
---|
public void setName(String name)
public void acquire() throws DatabaseException
Wait for the latch if some other thread is holding it. If there are threads waiting for access, they will be granted the latch on a FIFO basis. When the method returns, the latch is held for exclusive access.
LatchException
- if the latch is already held by the calling
thread.
RunRecoveryException
- if an InterruptedException exception
occurs.
DatabaseException
public boolean acquireNoWait() throws LatchException
LatchException
- if the latch is already held by the calling
thread.public void releaseIfOwner()
public void release() throws LatchNotHeldException
LatchNotHeldException
- if the latch is not currently held.public boolean isOwner()
Thread owner()
int nWaiters()
public LatchStats getLatchStats()
public String toString()
toString
in class Object
public static int countLatchesHeld()
public static void dumpLatchesHeld()
public static String latchesHeldToString()
public static void clearNotes()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |