@Override public int usage() { final int freeBytes; synchronized (arena) { freeBytes = this.freeBytes; } return usage(freeBytes); }
@Override public int usage() { final int freeBytes; synchronized (arena) { freeBytes = this.freeBytes; } return usage(freeBytes); }
@Override public int usage() { final int freeBytes; synchronized (arena) { freeBytes = this.freeBytes; } return usage(freeBytes); }
/** * Moves the {@link PoolChunk} down the {@link PoolChunkList} linked-list so it will end up in the right * {@link PoolChunkList} that has the correct minUsage / maxUsage in respect to {@link PoolChunk#usage()}. */ private boolean move0(PoolChunk<T> chunk) { if (prevList == null) { // There is no previous PoolChunkList so return false which result in having the PoolChunk destroyed and // all memory associated with the PoolChunk will be released. assert chunk.usage() == 0; return false; } return prevList.move(chunk); }
@Override public String toString() { final int freeBytes; synchronized (arena) { freeBytes = this.freeBytes; } return new StringBuilder() .append("Chunk(") .append(Integer.toHexString(System.identityHashCode(this))) .append(": ") .append(usage(freeBytes)) .append("%, ") .append(chunkSize - freeBytes) .append('/') .append(chunkSize) .append(')') .toString(); }
/** * Moves the {@link PoolChunk} down the {@link PoolChunkList} linked-list so it will end up in the right * {@link PoolChunkList} that has the correct minUsage / maxUsage in respect to {@link PoolChunk#usage()}. */ private boolean move0(PoolChunk<T> chunk) { if (prevList == null) { // There is no previous PoolChunkList so return false which result in having the PoolChunk destroyed and // all memory associated with the PoolChunk will be released. assert chunk.usage() == 0; return false; } return prevList.move(chunk); }
@Override public String toString() { final int freeBytes; synchronized (arena) { freeBytes = this.freeBytes; } return new StringBuilder() .append("Chunk(") .append(Integer.toHexString(System.identityHashCode(this))) .append(": ") .append(usage(freeBytes)) .append("%, ") .append(chunkSize - freeBytes) .append('/') .append(chunkSize) .append(')') .toString(); }
void add(PoolChunk<T> chunk) { if (chunk.usage() >= maxUsage) { nextList.add(chunk); return; } add0(chunk); }
/** * Moves the {@link PoolChunk} down the {@link PoolChunkList} linked-list so it will end up in the right * {@link PoolChunkList} that has the correct minUsage / maxUsage in respect to {@link PoolChunk#usage()}. */ private boolean move0(PoolChunk<T> chunk) { if (prevList == null) { // There is no previous PoolChunkList so return false which result in having the PoolChunk destroyed and // all memory associated with the PoolChunk will be released. assert chunk.usage() == 0; return false; } return prevList.move(chunk); }
@Override public String toString() { final int freeBytes; synchronized (arena) { freeBytes = this.freeBytes; } return new StringBuilder() .append("Chunk(") .append(Integer.toHexString(System.identityHashCode(this))) .append(": ") .append(usage(freeBytes)) .append("%, ") .append(chunkSize - freeBytes) .append('/') .append(chunkSize) .append(')') .toString(); }
void add(PoolChunk<T> chunk) { if (chunk.usage() >= maxUsage) { nextList.add(chunk); return; } add0(chunk); }
boolean free(PoolChunk<T> chunk, long handle, ByteBuffer nioBuffer) { chunk.free(handle, nioBuffer); if (chunk.usage() < minUsage) { remove(chunk); // Move the PoolChunk down the PoolChunkList linked-list. return move0(chunk); } return true; }
void add(PoolChunk<T> chunk) { if (chunk.usage() >= maxUsage) { nextList.add(chunk); return; } add0(chunk); }
boolean allocate(PooledByteBuf<T> buf, int reqCapacity, int normCapacity) { if (normCapacity > maxCapacity) { // Either this PoolChunkList is empty or the requested capacity is larger then the capacity which can // be handled by the PoolChunks that are contained in this PoolChunkList. return false; } for (PoolChunk<T> cur = head; cur != null; cur = cur.next) { if (cur.allocate(buf, reqCapacity, normCapacity)) { if (cur.usage() >= maxUsage) { remove(cur); nextList.add(cur); } return true; } } return false; }
boolean free(PoolChunk<T> chunk, long handle, ByteBuffer nioBuffer) { chunk.free(handle, nioBuffer); if (chunk.usage() < minUsage) { remove(chunk); // Move the PoolChunk down the PoolChunkList linked-list. return move0(chunk); } return true; }
boolean allocate(PooledByteBuf<T> buf, int reqCapacity, int normCapacity) { if (normCapacity > maxCapacity) { // Either this PoolChunkList is empty or the requested capacity is larger then the capacity which can // be handled by the PoolChunks that are contained in this PoolChunkList. return false; } for (PoolChunk<T> cur = head; cur != null; cur = cur.next) { if (cur.allocate(buf, reqCapacity, normCapacity)) { if (cur.usage() >= maxUsage) { remove(cur); nextList.add(cur); } return true; } } return false; }
boolean free(PoolChunk<T> chunk, long handle) { chunk.free(handle); if (chunk.usage() < minUsage) { remove(chunk); // Move the PoolChunk down the PoolChunkList linked-list. return move0(chunk); } return true; }