Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -51,7 +52,7 @@ public class AdaptiveBackOffSpinLockImpl implements AdaptiveBackOffSpinLock {

private final List<AtomicInteger> tpsTable;

private final List<Map<Thread, Byte>> threadTable;
private final List<Set<Thread>> threadTable;

private int swapCriticalPoint;

Expand All @@ -65,8 +66,8 @@ public AdaptiveBackOffSpinLockImpl() {
this.locks.put(BACK_OFF_SPIN_LOCK, new BackOffSpinLock());

this.threadTable = new ArrayList<>(2);
this.threadTable.add(new ConcurrentHashMap<>());
this.threadTable.add(new ConcurrentHashMap<>());
this.threadTable.add(ConcurrentHashMap.newKeySet());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

this.threadTable.add(ConcurrentHashMap.newKeySet());

this.tpsTable = new ArrayList<>(2);
this.tpsTable.add(new AtomicInteger(0));
Expand All @@ -78,7 +79,7 @@ public AdaptiveBackOffSpinLockImpl() {
@Override
public void lock() {
int slot = LocalTime.now().getSecond() % 2;
this.threadTable.get(slot).putIfAbsent(Thread.currentThread(), Byte.MAX_VALUE);
this.threadTable.get(slot).add(Thread.currentThread());
this.tpsTable.get(slot).getAndIncrement();
boolean state;
do {
Expand Down
Loading