Top Description Inners Fields Constructors Methods
io.netty.util.internal.shaded.org.jctools.maps

public Class ConcurrentAutoTable

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Static Imports
io.netty.util.internal.shaded.org.jctools.util.UnsafeAccess.UNSAFE

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.
Author
Cliff Click
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private volatile ConcurrentAutoTable.CAT
private static AtomicReferenceFieldUpdater<ConcurrentAutoTable, ConcurrentAutoTable.CAT>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(long x)

Add the given value to current counter value.

private long
add_if(long x)

private boolean
public void
decrement()

add with -1

public long
estimate_get()

A cheaper get.

public long
get()

Current value of the counter.

private static int
hash()

public void
increment()

add with +1

public int
internal_size()

Return the internal counter striping factor.

public int
intValue()

Same as get, included for completeness.

public long
longValue()

Same as get, included for completeness.

public void
set(long x)

Atomically set the sum of the striped counters to specified value.

public String
toString()

Overrides java.lang.Object.toString.

Return the counter's long value converted to a string.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_catback to summary
private volatile ConcurrentAutoTable.CAT _cat
_catUpdaterback to summary
private static AtomicReferenceFieldUpdater<ConcurrentAutoTable, ConcurrentAutoTable.CAT> _catUpdater

Constructor Detail

ConcurrentAutoTableback to summary
public ConcurrentAutoTable()

Method Detail

addback to summary
public void add(long x)

Add the given value to current counter value. Concurrent updates will not be lost, but addAndGet or getAndAdd are not implemented because the total counter value (i.e., 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.

add_ifback to summary
private long add_if(long x)
CAS_catback to summary
private boolean CAS_cat(ConcurrentAutoTable.CAT oldcat, ConcurrentAutoTable.CAT newcat)
decrementback to summary
public void decrement()

add with -1

estimate_getback to summary
public long estimate_get()

A cheaper get. Updated only once/millisecond, but as fast as a simple load instruction when not updating.

getback to summary
public long get()

Current value of the counter. Since other threads are updating furiously the value is only approximate, but it includes all counts made by the current thread. Requires a pass over the internally striped counters.

hashback to summary
private static int hash()
incrementback to summary
public void increment()

add with +1

internal_sizeback to summary
public int internal_size()

Return the internal counter striping factor. Useful for diagnosing performance problems.

intValueback to summary
public int intValue()

Same as get, included for completeness.

longValueback to summary
public long longValue()

Same as get, included for completeness.

setback to summary
public void set(long x)

Atomically set the sum of the striped counters to specified value. Rather more expensive than a simple store, in order to remain atomic.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return the counter's long value converted to a string.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

io.netty.util.internal.shaded.org.jctools.maps back to summary

private Class ConcurrentAutoTable.CAT

extends Object
implements Serializable
Class Inheritance
  • java.lang.Object
  • io.netty.util.internal.shaded.org.jctools.maps.ConcurrentAutoTable.CAT
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
private volatile long
private volatile long
private static final int
private static final int
private final ConcurrentAutoTable.CAT
private final long[]
private static final int

Constructor Summary

AccessConstructor and Description
pack-priv
CAT(ConcurrentAutoTable.CAT next, int sz, long init)

Method Summary

Modifier and TypeMethod and Description
public long
add_if(long x, int hash, ConcurrentAutoTable master)

private static boolean
CAS(long[] A, int idx, long old, long nnn)

public long
public void
private static long
rawIndex(long[] ary, int i)

public long
sum()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_fuzzy_sum_cacheback to summary
private volatile long _fuzzy_sum_cache
_fuzzy_timeback to summary
private volatile long _fuzzy_time
_Lbaseback to summary
private static final int _Lbase
_Lscaleback to summary
private static final int _Lscale
_nextback to summary
private final ConcurrentAutoTable.CAT _next
_tback to summary
private final long[] _t
MAX_SPINback to summary
private static final int MAX_SPIN

Constructor Detail

CATback to summary
pack-priv CAT(ConcurrentAutoTable.CAT next, int sz, long init)

Method Detail

add_ifback to summary
public long add_if(long x, int hash, ConcurrentAutoTable master)
CASback to summary
private static boolean CAS(long[] A, int idx, long old, long nnn)
estimate_sumback to summary
public long estimate_sum()
printback to summary
public void print()
rawIndexback to summary
private static long rawIndex(long[] ary, int i)
sumback to summary
public long sum()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object