public final class StripedCounters<T> extends Object
Callers must first obtain a stripe for the current thread with stripeForCurrentThread()
, then use increment(AtomicLongFieldUpdater, Object)
or add(AtomicLongFieldUpdater, Object, long)
to update one or
more counters in that stripe. They must also provide a AtomicLongFieldUpdater
to access a specific counter in
the stripe - it should be defined as static final
so that it can be inlined by the JIT.
Constructor and Description |
---|
StripedCounters(Supplier<T> stripeSupplier) |
Modifier and Type | Method and 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() |
public void increment(AtomicLongFieldUpdater<T> updater, T stripe)
public void add(AtomicLongFieldUpdater<T> updater, T stripe, long delta)
public long get(AtomicLongFieldUpdater<T> updater)
public void reset(AtomicLongFieldUpdater<T> updater)
public T stripeForCurrentThread()
Copyright © 2021 JBoss by Red Hat. All rights reserved.