|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.cliffc.high_scale_lib.ConcurrentAutoTable
public class ConcurrentAutoTable
An auto-resizing table of longs
, supporting low-contention CAS
operations. Updates are done with CAS's to no particular table element.
The intent is to support highly scalable counters, r/w locks, and other
structures where the updates are associative, loss-free (no-brainer), and
otherwise happen at such a high volume that the cache contention for
CAS'ing a single word is unacceptable.
This API is overkill for simple counters (e.g. no need for the 'mask') and is untested as an API for making a scalable r/w lock and so is likely to change!
Constructor Summary | |
---|---|
ConcurrentAutoTable()
|
Method Summary | |
---|---|
void |
add(long x)
Add the given value to current counter value. |
void |
decrement()
add(long) with -1 |
long |
estimate_get()
A cheaper get() . |
long |
get()
Current value of the counter. |
void |
increment()
add(long) with +1 |
int |
internal_size()
Return the internal counter striping factor. |
int |
intValue()
Same as get() , included for completeness. |
long |
longValue()
Same as get() , included for completeness. |
void |
print()
A more verbose print than toString() , showing internal structure. |
void |
set(long x)
Atomically set the sum of the striped counters to specified value. |
String |
toString()
Return the counter's long value converted to a string. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConcurrentAutoTable()
Method Detail |
---|
public void add(long x)
get()
) is not atomically updated.
Updates are striped across an array of counters to avoid cache contention
and has been tested with performance scaling linearly up to 768 CPUs.
public void decrement()
add(long)
with -1
public void increment()
add(long)
with +1
public void set(long x)
public long get()
public int intValue()
get()
, included for completeness.
public long longValue()
get()
, included for completeness.
public long estimate_get()
get()
. Updated only once/millisecond, but as fast as a
simple load instruction when not updating.
public String toString()
long
value converted to a string.
toString
in class Object
public void print()
toString()
, showing internal structure.
Useful for debugging.
public int internal_size()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |