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 @@ -7,7 +7,7 @@
package datadog.instrument.utils;

import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicInteger;

/**
* Shares class information from multiple classloaders in a single cache.
Expand All @@ -28,7 +28,7 @@ public final class ClassInfoCache<T> {
private static final int ALL_CLASS_LOADERS = -1;

// global monotonic counter; cheap way to track aging as info is shared
static final AtomicLong TICKS = new AtomicLong();
static final AtomicInteger TICKS = new AtomicInteger(Integer.MIN_VALUE);

// fixed-size hashtable of shared information, indexed by class-name
private final SharedInfo[] shared;
Expand Down Expand Up @@ -190,7 +190,7 @@ public void share(String className, T info, int classLoaderKeyId) {
// always wrap info in a new wrapper to avoid consistency issues
final SharedInfo update = new SharedInfo(className, info, classLoaderKeyId);

long oldestTick = Long.MAX_VALUE;
int oldestTick = Integer.MAX_VALUE;
int oldestSlot = -1;

// search by repeated hashing; stop when we find an empty slot,
Expand All @@ -200,7 +200,7 @@ public void share(String className, T info, int classLoaderKeyId) {
SharedInfo existing = shared[slot];
if (existing != null && !existing.equals(update)) {
// slot already used by a different class
long tick = existing.accessed;
int tick = existing.accessed;
if (i < MAX_HASH_ATTEMPTS) {
// still more slots to search
if (tick < oldestTick) {
Expand Down Expand Up @@ -246,7 +246,7 @@ static final class SharedInfo {
// optional class-loader key
final int classLoaderKeyId;

long accessed;
int accessed;

SharedInfo(String className, Object classInfo, int classLoaderKeyId) {
this.className = className;
Expand Down
Loading