Class StripedCounters<T>
- java.lang.Object
-
- org.infinispan.commons.util.concurrent.StripedCounters<T>
-
public final class StripedCounters<T> extends Object
Duplicates a set of counters in a set of stripes, so that multiple threads can increment those counters without too much contention.Callers must first obtain a stripe for the current thread with
stripeForCurrentThread()
, then useincrement(AtomicLongFieldUpdater, Object)
oradd(AtomicLongFieldUpdater, Object, long)
to update one or more counters in that stripe. They must also provide aAtomicLongFieldUpdater
to access a specific counter in the stripe - it should be defined asstatic final
so that it can be inlined by the JIT.- Since:
- 9.0
- Author:
- Dan Berindei
-
-
Constructor Summary
Constructors Constructor Description StripedCounters(Supplier<T> stripeSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(AtomicLongFieldUpdater<T> updater, T stripe, long delta)
long
get(AtomicLongFieldUpdater<T> updater)
void
increment(AtomicLongFieldUpdater<T> updater, T stripe)
void
reset(AtomicLongFieldUpdater<T> updater)
T
stripeForCurrentThread()
-
-
-
Method Detail
-
increment
public void increment(AtomicLongFieldUpdater<T> updater, T stripe)
-
add
public void add(AtomicLongFieldUpdater<T> updater, T stripe, long delta)
-
get
public long get(AtomicLongFieldUpdater<T> updater)
-
reset
public void reset(AtomicLongFieldUpdater<T> updater)
-
stripeForCurrentThread
public T stripeForCurrentThread()
-
-