Skip to content

Commit

Permalink
Remove old internal code that is not used anymore after removing usag…
Browse files Browse the repository at this point in the history
…e of ObjectCleaner (netty#8956)

Motivation:

We dont use ObjectCleaner in our FastThreadLocal anymore so we also dont need to take special care to store it there anymore.

Modifications:

Remove code that is not needed anymore.

Result:

Code cleanup.
  • Loading branch information
normanmaurer authored Mar 20, 2019
1 parent cb231e9 commit 9b1a59d
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions common/src/main/java/io/netty/util/concurrent/FastThreadLocal.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,33 +139,7 @@ public final V get() {
return (V) v;
}

V value = initialize(threadLocalMap);
registerCleaner(threadLocalMap);
return value;
}

private void registerCleaner(final InternalThreadLocalMap threadLocalMap) {
Thread current = Thread.currentThread();
if (FastThreadLocalThread.willCleanupFastThreadLocals(current) || threadLocalMap.isCleanerFlagSet(index)) {
return;
}

threadLocalMap.setCleanerFlag(index);

// TODO: We need to find a better way to handle this.
/*
// We will need to ensure we will trigger remove(InternalThreadLocalMap) so everything will be released
// and FastThreadLocal.onRemoval(...) will be called.
ObjectCleaner.register(current, new Runnable() {
@Override
public void run() {
remove(threadLocalMap);
// It's fine to not call InternalThreadLocalMap.remove() here as this will only be triggered once
// the Thread is collected by GC. In this case the ThreadLocal will be gone away already.
}
});
*/
return initialize(threadLocalMap);
}

/**
Expand Down Expand Up @@ -201,9 +175,7 @@ private V initialize(InternalThreadLocalMap threadLocalMap) {
public final void set(V value) {
if (value != InternalThreadLocalMap.UNSET) {
InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.get();
if (setKnownNotUnset(threadLocalMap, value)) {
registerCleaner(threadLocalMap);
}
setKnownNotUnset(threadLocalMap, value);
} else {
remove();
}
Expand All @@ -223,12 +195,10 @@ public final void set(InternalThreadLocalMap threadLocalMap, V value) {
/**
* @return see {@link InternalThreadLocalMap#setIndexedVariable(int, Object)}.
*/
private boolean setKnownNotUnset(InternalThreadLocalMap threadLocalMap, V value) {
private void setKnownNotUnset(InternalThreadLocalMap threadLocalMap, V value) {
if (threadLocalMap.setIndexedVariable(index, value)) {
addToVariablesToRemove(threadLocalMap, this);
return true;
}
return false;
}

/**
Expand Down

0 comments on commit 9b1a59d

Please sign in to comment.