Remove unused classes / Make HashedWheelTimer not use ReusableIterator
This commit is contained in:
parent
cda2d6f5aa
commit
391fe71639
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012 The Netty Project
|
|
||||||
*
|
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package io.netty.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents an object which contains another object that needs to be taken
|
|
||||||
* into account by {@link ObjectSizeEstimator} for more accurate object size
|
|
||||||
* estimation.
|
|
||||||
*/
|
|
||||||
public interface EstimatableObjectWrapper {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the underlying object that needs to be taken into account
|
|
||||||
* by {@link ObjectSizeEstimator} for more accurate object size estimation.
|
|
||||||
*/
|
|
||||||
Object unwrap();
|
|
||||||
}
|
|
@ -18,12 +18,12 @@ package io.netty.util;
|
|||||||
import io.netty.logging.InternalLogger;
|
import io.netty.logging.InternalLogger;
|
||||||
import io.netty.logging.InternalLoggerFactory;
|
import io.netty.logging.InternalLoggerFactory;
|
||||||
import io.netty.util.internal.DetectionUtil;
|
import io.netty.util.internal.DetectionUtil;
|
||||||
import io.netty.util.internal.ReusableIterator;
|
|
||||||
import io.netty.util.internal.SharedResourceMisuseDetector;
|
import io.netty.util.internal.SharedResourceMisuseDetector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -91,7 +91,6 @@ public class HashedWheelTimer implements Timer {
|
|||||||
private final long roundDuration;
|
private final long roundDuration;
|
||||||
final long tickDuration;
|
final long tickDuration;
|
||||||
final Set<HashedWheelTimeout>[] wheel;
|
final Set<HashedWheelTimeout>[] wheel;
|
||||||
final ReusableIterator<HashedWheelTimeout>[] iterators;
|
|
||||||
final int mask;
|
final int mask;
|
||||||
final ReadWriteLock lock = new ReentrantReadWriteLock();
|
final ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||||
volatile int wheelCursor;
|
volatile int wheelCursor;
|
||||||
@ -186,7 +185,6 @@ public class HashedWheelTimer implements Timer {
|
|||||||
|
|
||||||
// Normalize ticksPerWheel to power of two and initialize the wheel.
|
// Normalize ticksPerWheel to power of two and initialize the wheel.
|
||||||
wheel = createWheel(ticksPerWheel);
|
wheel = createWheel(ticksPerWheel);
|
||||||
iterators = createIterators(wheel);
|
|
||||||
mask = wheel.length - 1;
|
mask = wheel.length - 1;
|
||||||
|
|
||||||
// Convert tickDuration to milliseconds.
|
// Convert tickDuration to milliseconds.
|
||||||
@ -228,15 +226,6 @@ public class HashedWheelTimer implements Timer {
|
|||||||
return wheel;
|
return wheel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static ReusableIterator<HashedWheelTimeout>[] createIterators(Set<HashedWheelTimeout>[] wheel) {
|
|
||||||
ReusableIterator<HashedWheelTimeout>[] iterators = new ReusableIterator[wheel.length];
|
|
||||||
for (int i = 0; i < wheel.length; i ++) {
|
|
||||||
iterators[i] = (ReusableIterator<HashedWheelTimeout>) wheel[i].iterator();
|
|
||||||
}
|
|
||||||
return iterators;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int normalizeTicksPerWheel(int ticksPerWheel) {
|
private static int normalizeTicksPerWheel(int ticksPerWheel) {
|
||||||
int normalizedTicksPerWheel = 1;
|
int normalizedTicksPerWheel = 1;
|
||||||
while (normalizedTicksPerWheel < ticksPerWheel) {
|
while (normalizedTicksPerWheel < ticksPerWheel) {
|
||||||
@ -385,8 +374,7 @@ public class HashedWheelTimer implements Timer {
|
|||||||
lock.writeLock().lock();
|
lock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
int newWheelCursor = wheelCursor = wheelCursor + 1 & mask;
|
int newWheelCursor = wheelCursor = wheelCursor + 1 & mask;
|
||||||
ReusableIterator<HashedWheelTimeout> i = iterators[newWheelCursor];
|
fetchExpiredTimeouts(expiredTimeouts, wheel[newWheelCursor].iterator(), deadline);
|
||||||
fetchExpiredTimeouts(expiredTimeouts, i, deadline);
|
|
||||||
} finally {
|
} finally {
|
||||||
lock.writeLock().unlock();
|
lock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
@ -394,10 +382,9 @@ public class HashedWheelTimer implements Timer {
|
|||||||
|
|
||||||
private void fetchExpiredTimeouts(
|
private void fetchExpiredTimeouts(
|
||||||
List<HashedWheelTimeout> expiredTimeouts,
|
List<HashedWheelTimeout> expiredTimeouts,
|
||||||
ReusableIterator<HashedWheelTimeout> i, long deadline) {
|
Iterator<HashedWheelTimeout> i, long deadline) {
|
||||||
|
|
||||||
List<HashedWheelTimeout> slipped = null;
|
List<HashedWheelTimeout> slipped = null;
|
||||||
i.rewind();
|
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
HashedWheelTimeout timeout = i.next();
|
HashedWheelTimeout timeout = i.next();
|
||||||
if (timeout.remainingRounds <= 0) {
|
if (timeout.remainingRounds <= 0) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012 The Netty Project
|
|
||||||
*
|
|
||||||
* The Netty Project licenses this file to you under the Apache License,
|
|
||||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at:
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package io.netty.util.internal;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public interface ReusableIterator<E> extends Iterator<E> {
|
|
||||||
void rewind();
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user