Changes
This commit is contained in:
@@ -20,7 +20,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.kne.debug.TimeDebugger;
|
||||
import org.kne.membandboost.MembandBoost;
|
||||
|
||||
import jdk.internal.misc.Unsafe;
|
||||
public class ByteBufferAllocator {
|
||||
|
||||
public ByteBufferAllocator(boolean isDirect) {
|
||||
@@ -43,31 +42,8 @@ public class ByteBufferAllocator {
|
||||
throw new InternalError();
|
||||
return buf;
|
||||
}
|
||||
private static jdk.internal.misc.Unsafe usf;
|
||||
private static Method meth;
|
||||
static {
|
||||
Class<?> name;
|
||||
try {
|
||||
name = Class.forName("jdk.internal.misc.Unsafe");
|
||||
Field field = name.getDeclaredField("theUnsafe");
|
||||
field.setAccessible(true);
|
||||
usf= (Unsafe) field.get(null);
|
||||
meth=name.getMethod("allocateUninitializedArray", Class.class,int.class);
|
||||
|
||||
} catch (java.lang.reflect.InaccessibleObjectException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static byte[] allocateUninitializedArray(int capacity) {
|
||||
if(usf!=null) {
|
||||
return (byte[]) usf.allocateUninitializedArray(byte.class, capacity);
|
||||
}else {
|
||||
return new byte[capacity];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static ByteBuffer allocateHeap(int capacity) {
|
||||
/*if(capacity<=2048) {
|
||||
return MembandBoost.allocateUninitializedHeapBufferBlocked(capacity);
|
||||
@@ -75,10 +51,6 @@ public class ByteBufferAllocator {
|
||||
return MembandBoost.allocateUninitializedHeapBuffer(capacity);
|
||||
//}
|
||||
}
|
||||
public static ByteBuffer allocateHeap0(int capacity) {
|
||||
return ByteBuffer.wrap((byte[])allocateUninitializedArray(capacity)) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user