Package org.redisson.misc
Class ReclosableLatch
- java.lang.Object
-
- java.util.concurrent.locks.AbstractOwnableSynchronizer
-
- java.util.concurrent.locks.AbstractQueuedSynchronizer
-
- org.redisson.misc.ReclosableLatch
-
- All Implemented Interfaces:
Serializable
public class ReclosableLatch extends AbstractQueuedSynchronizer
A thread gate, that uses anAbstractQueuedSynchronizer
.This implementation allows you to create a latch with a default state (open or closed), and repeatedly open or close the latch.
- Since:
- 4.0
- Author:
- Manik Surtani ([email protected])
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizer
AbstractQueuedSynchronizer.ConditionObject
-
-
Constructor Summary
Constructors Constructor Description ReclosableLatch()
ReclosableLatch(boolean defaultOpen)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
await()
boolean
await(long time, TimeUnit unit)
void
awaitUninterruptibly()
void
close()
boolean
isOpened()
void
open()
String
toString()
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, hasQueuedPredecessors, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryRelease
-
Methods inherited from class java.util.concurrent.locks.AbstractOwnableSynchronizer
getExclusiveOwnerThread, setExclusiveOwnerThread
-
-
-
-
Method Detail
-
tryAcquireShared
public final int tryAcquireShared(int ignored)
- Overrides:
tryAcquireShared
in classAbstractQueuedSynchronizer
-
tryReleaseShared
public final boolean tryReleaseShared(int state)
- Overrides:
tryReleaseShared
in classAbstractQueuedSynchronizer
-
open
public final void open()
-
close
public final void close()
-
isOpened
public boolean isOpened()
-
await
public final void await() throws InterruptedException
- Throws:
InterruptedException
-
awaitUninterruptibly
public final void awaitUninterruptibly()
-
await
public final boolean await(long time, TimeUnit unit) throws InterruptedException
- Throws:
InterruptedException
-
toString
public String toString()
- Overrides:
toString
in classAbstractQueuedSynchronizer
-
-