Package org.onlab.util
Class BlockingBoolean
- java.lang.Object
- 
- java.util.concurrent.locks.AbstractOwnableSynchronizer
- 
- java.util.concurrent.locks.AbstractQueuedSynchronizer
- 
- org.onlab.util.BlockingBoolean
 
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable
 
 public class BlockingBoolean extends java.util.concurrent.locks.AbstractQueuedSynchronizerMutable boolean that allows threads to wait for a specified value.- See Also:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description BlockingBoolean(boolean value)Creates a new blocking boolean with the specified value.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawait(boolean value)Causes the current thread to wait until the boolean equals the specified value unless the thread is interrupted.booleanawait(boolean value, long timeout, java.util.concurrent.TimeUnit unit)Causes the current thread to wait until the boolean equals the specified value unless the thread is interrupted, or the specified waiting time elapses.booleanget()Gets the value of the blocking boolean.voidset(boolean value)Sets the value of the blocking boolean.protected inttryAcquireShared(int acquires)protected booleantryReleaseShared(int releases)- 
Methods inherited from class java.util.concurrent.locks.AbstractQueuedSynchronizeracquire, acquireInterruptibly, acquireShared, acquireSharedInterruptibly, compareAndSetState, getExclusiveQueuedThreads, getFirstQueuedThread, getQueuedThreads, getQueueLength, getSharedQueuedThreads, getState, getWaitingThreads, getWaitQueueLength, hasContended, hasQueuedPredecessors, hasQueuedThreads, hasWaiters, isHeldExclusively, isQueued, owns, release, releaseShared, setState, toString, tryAcquire, tryAcquireNanos, tryAcquireSharedNanos, tryRelease
 
- 
 
- 
- 
- 
Method Detail- 
awaitpublic void await(boolean value) throws java.lang.InterruptedExceptionCauses the current thread to wait until the boolean equals the specified value unless the thread is interrupted.- Parameters:
- value- specified value
- Throws:
- java.lang.InterruptedException- if interrupted while waiting
 
 - 
awaitpublic boolean await(boolean value, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionCauses the current thread to wait until the boolean equals the specified value unless the thread is interrupted, or the specified waiting time elapses.- Parameters:
- value- specified value
- timeout- the maximum time to wait
- unit- the time unit of the- timeoutargument
- Returns:
- trueif the count reached zero and- falseif the waiting time elapsed before the count reached zero
- Throws:
- java.lang.InterruptedException- if interrupted while waiting
 
 - 
tryAcquireSharedprotected int tryAcquireShared(int acquires) - Overrides:
- tryAcquireSharedin class- java.util.concurrent.locks.AbstractQueuedSynchronizer
 
 - 
setpublic void set(boolean value) Sets the value of the blocking boolean.- Parameters:
- value- new value
 
 - 
getpublic boolean get() Gets the value of the blocking boolean.- Returns:
- current value
 
 - 
tryReleaseSharedprotected boolean tryReleaseShared(int releases) - Overrides:
- tryReleaseSharedin class- java.util.concurrent.locks.AbstractQueuedSynchronizer
 
 
- 
 
-