Package com.attivio.concurrent
Class WaitableBoolean
- java.lang.Object
- 
- com.attivio.concurrent.SynchronizedVariable
- 
- com.attivio.concurrent.SynchronizedBoolean
- 
- com.attivio.concurrent.WaitableBoolean
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Comparable<SynchronizedBoolean>,- java.util.concurrent.Executor
 
 public class WaitableBoolean extends SynchronizedBoolean A class useful for offloading synch for boolean instance variables.
- 
- 
Field Summary- 
Fields inherited from class com.attivio.concurrent.SynchronizedBooleanvalue
 - 
Fields inherited from class com.attivio.concurrent.SynchronizedVariablelock
 
- 
 - 
Constructor SummaryConstructors Constructor Description WaitableBoolean(boolean initialValue)Make a new WaitableBoolean with the given initial value *WaitableBoolean(boolean initialValue, java.util.concurrent.locks.ReadWriteLock lock)Make a new WaitableBoolean with the given initial value, and using the supplied lock.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanand(boolean b)Set value to value & b.booleancommit(boolean assumedValue, boolean newValue)Set value to newValue only if it is currently assumedValue.booleancomplement()Set the value to its complementbooleanequals(java.lang.Object other)inthashCode()booleanor(boolean b)Set value to value | b.booleanset(boolean newValue)Set to newValue.voidwaitForChange()Waits for the value to change for up to 5secs.voidwhenEqual(boolean c, java.lang.Runnable action)Wait until value equals c, then run action if nonnull.voidwhenFalse(java.lang.Runnable action)Wait until value is false, then run action if nonnull.voidwhenNotEqual(boolean c, java.lang.Runnable action)wait until value not equal to c, then run action if nonnull.voidwhenTrue(java.lang.Runnable action)wait until value is true, then run action if nonnull.booleanxor(boolean b)Set value to value ^ b.- 
Methods inherited from class com.attivio.concurrent.SynchronizedBooleancompareTo, compareTo, get, swap, toString
 - 
Methods inherited from class com.attivio.concurrent.SynchronizedVariableexecute, getLock
 
- 
 
- 
- 
- 
Constructor Detail- 
WaitableBooleanpublic WaitableBoolean(boolean initialValue) Make a new WaitableBoolean with the given initial value *
 - 
WaitableBooleanpublic WaitableBoolean(boolean initialValue, java.util.concurrent.locks.ReadWriteLock lock)Make a new WaitableBoolean with the given initial value, and using the supplied lock.
 
- 
 - 
Method Detail- 
equalspublic boolean equals(java.lang.Object other) - Overrides:
- equalsin class- SynchronizedBoolean
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- SynchronizedBoolean
 
 - 
setpublic boolean set(boolean newValue) Description copied from class:SynchronizedBooleanSet to newValue.- Overrides:
- setin class- SynchronizedBoolean
- Returns:
- the old value
 
 - 
commitpublic boolean commit(boolean assumedValue, boolean newValue)Description copied from class:SynchronizedBooleanSet value to newValue only if it is currently assumedValue.- Overrides:
- commitin class- SynchronizedBoolean
- Returns:
- true if successful
 
 - 
complementpublic boolean complement() Description copied from class:SynchronizedBooleanSet the value to its complement- Overrides:
- complementin class- SynchronizedBoolean
- Returns:
- the new value
 
 - 
andpublic boolean and(boolean b) Description copied from class:SynchronizedBooleanSet value to value & b.- Overrides:
- andin class- SynchronizedBoolean
- Returns:
- the new value
 
 - 
orpublic boolean or(boolean b) Description copied from class:SynchronizedBooleanSet value to value | b.- Overrides:
- orin class- SynchronizedBoolean
- Returns:
- the new value
 
 - 
xorpublic boolean xor(boolean b) Description copied from class:SynchronizedBooleanSet value to value ^ b.- Overrides:
- xorin class- SynchronizedBoolean
- Returns:
- the new value
 
 - 
whenFalsepublic void whenFalse(java.lang.Runnable action) throws java.lang.InterruptedExceptionWait until value is false, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
- java.lang.InterruptedException
 
 - 
whenTruepublic void whenTrue(java.lang.Runnable action) throws java.lang.InterruptedExceptionwait until value is true, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
- java.lang.InterruptedException
 
 - 
whenEqualpublic void whenEqual(boolean c, java.lang.Runnable action) throws java.lang.InterruptedExceptionWait until value equals c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
- java.lang.InterruptedException
 
 - 
whenNotEqualpublic void whenNotEqual(boolean c, java.lang.Runnable action) throws java.lang.InterruptedExceptionwait until value not equal to c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
- java.lang.InterruptedException
 
 - 
waitForChangepublic void waitForChange() throws java.lang.InterruptedExceptionWaits for the value to change for up to 5secs. State must be re-checked after this method returns.- Throws:
- java.lang.InterruptedException
 
 
- 
 
-