org.jboss.cache.util.concurrent
Class ReclosableLatch

java.lang.Object
  extended by java.util.concurrent.locks.AbstractQueuedSynchronizer
      extended by org.jboss.cache.util.concurrent.ReclosableLatch
All Implemented Interfaces:
Serializable

public class ReclosableLatch
extends AbstractQueuedSynchronizer

This latch allows you to set a default state (open or closed), and repeatedly open or close the latch and have threads wait on it.

This is a better impl of the old org.jboss.cache.util.ThreadGate (which doesn't exist anymore), that uses an AbstractQueuedSynchronizer while ThreadGate used to use explicit Lock objects.

Since:
3.0
Author:
Manik Surtani (manik AT jboss DOT org)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
AbstractQueuedSynchronizer.ConditionObject
 
Constructor Summary
ReclosableLatch()
           
ReclosableLatch(boolean defaultOpen)
           
 
Method Summary
 void await()
           
 boolean await(long time, TimeUnit unit)
           
 void close()
           
 boolean isOpen()
           
 void open()
           
 int tryAcquireShared(int ignored)
           
 boolean tryReleaseShared(int state)
           
 
Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
acquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, toString, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryRelease
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReclosableLatch

public ReclosableLatch()

ReclosableLatch

public ReclosableLatch(boolean defaultOpen)
Method Detail

tryAcquireShared

public final int tryAcquireShared(int ignored)
Overrides:
tryAcquireShared in class AbstractQueuedSynchronizer

tryReleaseShared

public final boolean tryReleaseShared(int state)
Overrides:
tryReleaseShared in class AbstractQueuedSynchronizer

open

public final void open()

close

public final void close()

await

public final void await()
                 throws InterruptedException
Throws:
InterruptedException

await

public final boolean await(long time,
                           TimeUnit unit)
                    throws InterruptedException
Throws:
InterruptedException

isOpen

public boolean isOpen()


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.