@VisibleForTesting void reset() { Chunk parent = getParentChunk(slab); if (parent != null) parent.free(slab, false); else FileUtils.clean(slab); }
if (!releaseAttachment(buffer)) return 1L; assert (address >= baseAddress) & (address <= baseAddress + capacity()); int size = roundUp(buffer.capacity()); assert size == capacity(); assert position == 0; shiftedSlotBits = -1L;
if (!releaseAttachment(buffer)) return 1L; assert (address >= baseAddress) & (address <= baseAddress + capacity()); int size = roundUp(buffer.capacity()); assert size == capacity(); assert position == 0; shiftedSlotBits = -1L;
if (!releaseAttachment(buffer)) return 1L; assert (address >= baseAddress) & (address <= baseAddress + capacity()); int size = roundUp(buffer.capacity()); assert size == capacity(); assert position == 0; shiftedSlotBits = -1L;
if (!releaseAttachment(buffer)) return 1L; assert (address >= baseAddress) & (address <= baseAddress + capacity()); int size = roundUp(buffer.capacity()); assert size == capacity(); assert position == 0; shiftedSlotBits = -1L;
public void put(ByteBuffer buffer) { Chunk chunk = Chunk.getParentChunk(buffer); if (chunk == null) { FileUtils.clean(buffer); return; } LocalPool owner = chunk.owner; // ask the free method to take exclusive ownership of the act of recycling // if we are either: already not owned by anyone, or owned by ourselves long free = chunk.free(buffer, owner == null | owner == this); if (free == 0L) { // 0L => we own recycling responsibility, so must recycle; chunk.recycle(); // if we are also the owner, we must remove the Chunk from our local queue if (owner == this) removeFromLocalQueue(chunk); } else if (((free == -1L) && owner != this) && chunk.owner == null) { // although we try to take recycle ownership cheaply, it is not always possible to do so if the owner is racing to unset. // we must also check after completely freeing if the owner has since been unset, and try to recycle chunk.tryRecycle(); } }
public void put(ByteBuffer buffer) { Chunk chunk = Chunk.getParentChunk(buffer); if (chunk == null) { FileUtils.clean(buffer); return; } LocalPool owner = chunk.owner; // ask the free method to take exclusive ownership of the act of recycling // if we are either: already not owned by anyone, or owned by ourselves long free = chunk.free(buffer, owner == null | owner == this); if (free == 0L) { // 0L => we own recycling responsibility, so must recycle; chunk.recycle(); // if we are also the owner, we must remove the Chunk from our local queue if (owner == this) removeFromLocalQueue(chunk); } else if (((free == -1L) && owner != this) && chunk.owner == null) { // although we try to take recycle ownership cheaply, it is not always possible to do so if the owner is racing to unset. // we must also check after completely freeing if the owner has since been unset, and try to recycle chunk.tryRecycle(); } }
public void put(ByteBuffer buffer) { Chunk chunk = Chunk.getParentChunk(buffer); if (chunk == null) { FileUtils.clean(buffer); return; } LocalPool owner = chunk.owner; // ask the free method to take exclusive ownership of the act of recycling // if we are either: already not owned by anyone, or owned by ourselves long free = chunk.free(buffer, owner == null | owner == this); if (free == 0L) { // 0L => we own recycling responsibility, so must recycle; chunk.recycle(); // if we are also the owner, we must remove the Chunk from our local queue if (owner == this) removeFromLocalQueue(chunk); } else if (((free == -1L) && owner != this) && chunk.owner == null) { // although we try to take recycle ownership cheaply, it is not always possible to do so if the owner is racing to unset. // we must also check after completely freeing if the owner has since been unset, and try to recycle chunk.tryRecycle(); } }
public void put(ByteBuffer buffer) { Chunk chunk = Chunk.getParentChunk(buffer); if (chunk == null) { FileUtils.clean(buffer); return; } LocalPool owner = chunk.owner; // ask the free method to take exclusive ownership of the act of recycling // if we are either: already not owned by anyone, or owned by ourselves long free = chunk.free(buffer, owner == null | owner == this); if (free == 0L) { // 0L => we own recycling responsibility, so must recycle; chunk.recycle(); // if we are also the owner, we must remove the Chunk from our local queue if (owner == this) removeFromLocalQueue(chunk); } else if (((free == -1L) && owner != this) && chunk.owner == null) { // although we try to take recycle ownership cheaply, it is not always possible to do so if the owner is racing to unset. // we must also check after completely freeing if the owner has since been unset, and try to recycle chunk.tryRecycle(); } }
private void addChunk(Chunk chunk) { chunk.acquire(this); if (chunkCount < 3) { chunks[chunkCount++] = chunk; return; } int smallestChunkIdx = 0; if (chunks[1].free() < chunks[0].free()) smallestChunkIdx = 1; if (chunks[2].free() < chunks[smallestChunkIdx].free()) smallestChunkIdx = 2; chunks[smallestChunkIdx].release(); if (smallestChunkIdx != 2) chunks[smallestChunkIdx] = chunks[2]; chunks[2] = chunk; }
private void addChunk(Chunk chunk) { chunk.acquire(this); if (chunkCount < 3) { chunks[chunkCount++] = chunk; return; } int smallestChunkIdx = 0; if (chunks[1].free() < chunks[0].free()) smallestChunkIdx = 1; if (chunks[2].free() < chunks[smallestChunkIdx].free()) smallestChunkIdx = 2; chunks[smallestChunkIdx].release(); if (smallestChunkIdx != 2) chunks[smallestChunkIdx] = chunks[2]; chunks[2] = chunk; }