private UnexpandableByteBuffer allocate0(int capacity, boolean direct) {
ExpiringStack[] bufferStacks = direct ? directBufferStacks
: heapBufferStacks;
int idx = getBufferStackIndex(bufferStacks, capacity);
ExpiringStack stack = bufferStacks[idx];
UnexpandableByteBuffer buf;
synchronized (stack) {
buf = (UnexpandableByteBuffer) stack.pop();
}
if (buf == null) {
java.nio.ByteBuffer nioBuf = direct ? java.nio.ByteBuffer
.allocateDirect(MINIMUM_CAPACITY << idx)