moved methods to java-util

This commit is contained in:
Xavier Léauté 2014-12-05 15:53:23 -08:00
parent ad23e49777
commit 629f6bc759
1 changed files with 0 additions and 25 deletions

View File

@ -23,8 +23,6 @@ import com.google.common.base.Supplier;
import com.metamx.common.logger.Logger;
import io.druid.collections.StupidPool;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicLong;
@ -33,29 +31,6 @@ public class OffheapBufferPool extends StupidPool<ByteBuffer>
{
private static final Logger log = new Logger(OffheapBufferPool.class);
private static final Method bufferCleaner;
private static final Method clean;
static {
try {
bufferCleaner = Class.forName("java.nio.DirectByteBuffer").getMethod("cleaner");
bufferCleaner.setAccessible(true);
clean = Class.forName("sum.misc.Cleaner").getMethod("clean");
clean.setAccessible(true);
} catch(ClassNotFoundException | NoSuchMethodException e) {
throw new RuntimeException("Unable to access ByteBuffer release methods");
}
}
private static void releaseBuffer(ByteBuffer buf) {
try {
Object cleaner = bufferCleaner.invoke(buf);
clean.invoke(cleaner);
} catch(IllegalAccessException | InvocationTargetException e) {
log.error(e, "Unable to release ByteBuffer");
}
}
public OffheapBufferPool(final int computationBufferSize)
{
super(