Package com.attivio.concurrent
Class SynchronizedBoolean
- java.lang.Object
- 
- com.attivio.concurrent.SynchronizedVariable
- 
- com.attivio.concurrent.SynchronizedBoolean
 
 
- 
- All Implemented Interfaces:
- java.lang.Comparable<SynchronizedBoolean>,- java.util.concurrent.Executor
 - Direct Known Subclasses:
- WaitableBoolean
 
 public class SynchronizedBoolean extends SynchronizedVariable implements java.lang.Comparable<SynchronizedBoolean> A class useful for offloading synch for boolean instance variables.
- 
- 
Field SummaryFields Modifier and Type Field Description protected booleanvaluethe actual value- 
Fields inherited from class com.attivio.concurrent.SynchronizedVariablelock
 
- 
 - 
Constructor SummaryConstructors Constructor Description SynchronizedBoolean(boolean initialValue)Make a new SynchronizedBoolean with the given initial value, and using its own internal lock.SynchronizedBoolean(boolean initialValue, java.util.concurrent.locks.ReadWriteLock lock)Make a new SynchronizedBoolean 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.intcompareTo(boolean other)intcompareTo(SynchronizedBoolean other)booleancomplement()Set the value to its complementbooleanequals(java.lang.Object other)booleanget()Return the current valueinthashCode()booleanor(boolean b)Set value to value | b.booleanset(boolean newValue)Set to newValue.booleanswap(SynchronizedBoolean other)Atomically swap values with another SynchronizedBoolean.java.lang.StringtoString()booleanxor(boolean b)Set value to value ^ b.- 
Methods inherited from class com.attivio.concurrent.SynchronizedVariableexecute, getLock
 
- 
 
- 
- 
- 
Constructor Detail- 
SynchronizedBooleanpublic SynchronizedBoolean(boolean initialValue) Make a new SynchronizedBoolean with the given initial value, and using its own internal lock.
 - 
SynchronizedBooleanpublic SynchronizedBoolean(boolean initialValue, java.util.concurrent.locks.ReadWriteLock lock)Make a new SynchronizedBoolean with the given initial value, and using the supplied lock.
 
- 
 - 
Method Detail- 
getpublic final boolean get() Return the current value
 - 
setpublic boolean set(boolean newValue) Set to newValue.- Returns:
- the old value
 
 - 
commitpublic boolean commit(boolean assumedValue, boolean newValue)Set value to newValue only if it is currently assumedValue.- Returns:
- true if successful
 
 - 
swappublic boolean swap(SynchronizedBoolean other) Atomically swap values with another SynchronizedBoolean. Uses identityHashCode to avoid deadlock when two SynchronizedBooleans attempt to simultaneously swap with each other. (Note: Ordering via identyHashCode is not strictly guaranteed by the language specification to return unique, orderable values, but in practice JVMs rely on them being unique.)- Returns:
- the new value
 
 - 
complementpublic boolean complement() Set the value to its complement- Returns:
- the new value
 
 - 
andpublic boolean and(boolean b) Set value to value & b.- Returns:
- the new value
 
 - 
orpublic boolean or(boolean b) Set value to value | b.- Returns:
- the new value
 
 - 
xorpublic boolean xor(boolean b) Set value to value ^ b.- Returns:
- the new value
 
 - 
compareTopublic int compareTo(boolean other) 
 - 
compareTopublic int compareTo(SynchronizedBoolean other) - Specified by:
- compareToin interface- java.lang.Comparable<SynchronizedBoolean>
 
 - 
equalspublic boolean equals(java.lang.Object other) - Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-