public class CAT extends Object implements Externalizable
CATs are
useful when a counter is extremely hot for updates and adaptively expand
their internal state to minimize thread contention. However, they can do more
work than an AtomicLong on read since they must scan an internal
table to aggregate updates from various threads.
Note: The class uses a delegation pattern in order to replace the serialization logic with a simple serialized long value.
ConcurrentAutoTable,
Serialized Form| Constructor and Description |
|---|
CAT()
Initialize a new counter with a value of
0L. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(long x)
Add the value to the counter.
|
void |
decrement()
Decrement the value of the counter.
|
long |
estimate_get()
Estimate the current value of the counter.
|
long |
get()
Current value of the counter.
|
void |
increment()
Increment the value of the counter.
|
void |
readExternal(ObjectInput in) |
void |
set(long x)
Set the value of the counter.
|
String |
toString()
Return the current value of the counter.
|
void |
writeExternal(ObjectOutput out) |
public final void add(long x)
ConcurrentAutoTable.add(long)public final void decrement()
ConcurrentAutoTable.decrement()public final void increment()
ConcurrentAutoTable.increment()public final void set(long x)
ConcurrentAutoTable.set(long)public final long get()
ConcurrentAutoTable.get()public final long estimate_get()
ConcurrentAutoTable.estimate_get()public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionCopyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.