|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Number
edu.rit.pj.reduction.SharedShort
public class SharedShort
Class SharedShort provides a reduction variable for a value of type short.
Class SharedShort is multiple thread safe. The methods use lock-free atomic compare-and-set.
Note: Class SharedShort is implemented using class java.util.concurrent.atomic.AtomicInteger. The short value is stored as an int whose values are restricted to the range of type short.
| Constructor Summary | |
|---|---|
SharedShort()
Construct a new short reduction variable with the initial value 0. |
|
SharedShort(short initialValue)
Construct a new short reduction variable with the given initial value. |
|
| Method Summary | |
|---|---|
short |
addAndGet(short value)
Add the given value to this reduction variable and return the new value. |
boolean |
compareAndSet(short expect,
short update)
Atomically set this reduction variable to the given updated value if the current value equals the expected value. |
short |
decrementAndGet()
Subtract one from this reduction variable and return the new value. |
double |
doubleValue()
Returns this reduction variable's current value converted to type double. |
float |
floatValue()
Returns this reduction variable's current value converted to type float. |
short |
get()
Returns this reduction variable's current value. |
short |
getAndAdd(short value)
Add the given value to this reduction variable and return the previous value. |
short |
getAndDecrement()
Subtract one from this reduction variable and return the previous value. |
short |
getAndIncrement()
Add one to this reduction variable and return the previous value. |
short |
getAndSet(short value)
Set this reduction variable to the given value and return the previous value. |
short |
incrementAndGet()
Add one to this reduction variable and return the new value. |
int |
intValue()
Returns this reduction variable's current value converted to type int. |
long |
longValue()
Returns this reduction variable's current value converted to type long. |
short |
reduce(short value,
ShortOp op)
Combine this reduction variable with the given value using the given operation. |
void |
set(short value)
Set this reduction variable to the given value. |
String |
toString()
Returns a string version of this reduction variable. |
boolean |
weakCompareAndSet(short expect,
short update)
Atomically set this reduction variable to the given updated value if the current value equals the expected value. |
| Methods inherited from class java.lang.Number |
|---|
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SharedShort()
public SharedShort(short initialValue)
initialValue - Initial value.| Method Detail |
|---|
public short get()
public void set(short value)
value - New value.public short getAndSet(short value)
value - New value.
public boolean compareAndSet(short expect,
short update)
expect - Expected value.update - Updated value.
public boolean weakCompareAndSet(short expect,
short update)
expect - Expected value.update - Updated value.
public short getAndIncrement()
public short getAndDecrement()
public short getAndAdd(short value)
value - Value to add.
public short incrementAndGet()
public short decrementAndGet()
public short addAndGet(short value)
value - Value to add.
public short reduce(short value,
ShortOp op)
value - Value.op - Binary operation.
public String toString()
toString in class Objectpublic int intValue()
intValue in class Numberpublic long longValue()
longValue in class Numberpublic float floatValue()
floatValue in class Numberpublic double doubleValue()
doubleValue in class Number
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||