|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.logicalcobwebs.concurrent.SynchronizedVariable org.logicalcobwebs.concurrent.SynchronizedInt
public class SynchronizedInt
A class useful for offloading synch for int instance variables.
[ Introduction to this package. ]
Field Summary | |
---|---|
protected int |
value_
|
Fields inherited from class org.logicalcobwebs.concurrent.SynchronizedVariable |
---|
lock_ |
Constructor Summary | |
---|---|
SynchronizedInt(int initialValue)
Make a new SynchronizedInt with the given initial value, and using its own internal lock. |
|
SynchronizedInt(int initialValue,
java.lang.Object lock)
Make a new SynchronizedInt with the given initial value, and using the supplied lock. |
Method Summary | |
---|---|
int |
add(int amount)
Add amount to value (i.e., set value += amount) |
int |
and(int b)
Set value to value & b. |
boolean |
commit(int assumedValue,
int newValue)
Set value to newValue only if it is currently assumedValue. |
int |
compareTo(int other)
|
int |
compareTo(java.lang.Object other)
|
int |
compareTo(SynchronizedInt other)
|
int |
complement()
Set the value to its complement |
int |
decrement()
Decrement the value. |
int |
divide(int factor)
Divide value by factor (i.e., set value /= factor) |
boolean |
equals(java.lang.Object other)
|
int |
get()
Return the current value |
int |
hashCode()
|
int |
increment()
Increment the value. |
int |
multiply(int factor)
Multiply value by factor (i.e., set value *= factor) |
int |
negate()
Set the value to the negative of its old value |
int |
or(int b)
Set value to value | b. |
int |
set(int newValue)
Set to newValue. |
int |
subtract(int amount)
Subtract amount from value (i.e., set value -= amount) |
int |
swap(SynchronizedInt other)
Atomically swap values with another SynchronizedInt. |
java.lang.String |
toString()
|
int |
xor(int b)
Set value to value ^ b. |
Methods inherited from class org.logicalcobwebs.concurrent.SynchronizedVariable |
---|
execute, getLock |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int value_
Constructor Detail |
---|
public SynchronizedInt(int initialValue)
public SynchronizedInt(int initialValue, java.lang.Object lock)
Method Detail |
---|
public final int get()
public int set(int newValue)
public boolean commit(int assumedValue, int newValue)
public int swap(SynchronizedInt other)
public int increment()
public int decrement()
public int add(int amount)
public int subtract(int amount)
public int multiply(int factor)
public int divide(int factor)
public int negate()
public int complement()
public int and(int b)
public int or(int b)
public int xor(int b)
public int compareTo(int other)
public int compareTo(SynchronizedInt other)
public int compareTo(java.lang.Object other)
compareTo
in interface java.lang.Comparable
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |