com.sleepycat.je.utilint
Class TimingLatch

java.lang.Object
  extended by com.sleepycat.je.latch.Latch
      extended by com.sleepycat.je.utilint.TimingLatch

public class TimingLatch
extends Latch

A subclass of Latch that may be used for debugging performance issues. This latch can be used in place of an exclusive latch or object mutex in order to see who is waiting for a latch acquisition, how long they're waiting, and who the previous holder was. It crudely writes to System.out, but this can easily be changed to a java.util.Log or EventTrace as desired. You can specify a threshold for the wait and previous holder time (nanos).


Nested Class Summary
 class TimingLatch.AcquireCompleteEvent
           
 class TimingLatch.AcquireRequestEvent
           
 class TimingLatch.ReleaseEvent
           
 
Constructor Summary
TimingLatch(String name, boolean debug)
           
TimingLatch(String name, boolean debug, int waitThreshold, int holdThreshold)
           
 
Method Summary
 void acquire()
          Acquire a latch for exclusive/write access.
 void release()
          Release the latch.
 
Methods inherited from class com.sleepycat.je.latch.Latch
acquireNoWait, clear, getLatchStats, getName, isOwner, nWaiters, owner, releaseIfOwner, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimingLatch

public TimingLatch(String name,
                   boolean debug)

TimingLatch

public TimingLatch(String name,
                   boolean debug,
                   int waitThreshold,
                   int holdThreshold)
Method Detail

release

public void release()
Description copied from class: Latch
Release the latch. If there are other thread(s) waiting for the latch, they are woken up and granted the latch.

Overrides:
release in class Latch

acquire

public void acquire()
Description copied from class: Latch
Acquire a latch for exclusive/write access.

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.

Overrides:
acquire in class Latch


Copyright (c) 2004-2012 Oracle. All rights reserved.