@Test public void emptyMemorySegmentPoolDoesNotAllocateSegments() { MemorySegmentPool pool = new MemorySegmentPool(0); assertThat(pool.nextSegment(), nullValue()); }
@Nullable @Override public MemorySegment nextSegment() { MemorySegment segment = pool.pollFirst(); if (segment != null) { return segment; } if (!hasRemainingCapacity()) { return null; } segment = MemorySegmentFactory.allocateUnpooledSegment(PAGE_SIZE); totalAllocatedMemory += PAGE_SIZE; return segment; }
MemorySegmentPool implements MemorySegmentSource { @Nullable @Override public MemorySegment nextSegment() { MemorySegment segment = pool.pollFirst(); if (segment != null) { return segment; } if (!hasRemainingCapacity()) { return null; } segment = MemorySegmentFactory.allocateUnpooledSegment(PAGE_SIZE); totalAllocatedMemory += PAGE_SIZE; return segment; } }
MemorySegmentPool implements MemorySegmentSource { @Nullable @Override public MemorySegment nextSegment() { MemorySegment segment = pool.pollFirst(); if (segment != null) { return segment; } if (!hasRemainingCapacity()) { return null; } segment = MemorySegmentFactory.allocateUnpooledSegment(PAGE_SIZE); totalAllocatedMemory += PAGE_SIZE; return segment; } MemorySegmentPool(long inMemoryBufferSize); }
MemorySegmentPool implements MemorySegmentSource { @Nullable @Override public MemorySegment nextSegment() { MemorySegment segment = pool.pollFirst(); if (segment != null) { return segment; } if (!hasRemainingCapacity()) { return null; } segment = MemorySegmentFactory.allocateUnpooledSegment(PAGE_SIZE); totalAllocatedMemory += PAGE_SIZE; return segment; } MemorySegmentPool(long inMemoryBufferSize); @Nullable @Override MemorySegment nextSegment(); }
MemorySegmentPool implements MemorySegmentSource { @Nullable @Override public MemorySegment nextSegment() { MemorySegment segment = pool.pollFirst(); if (segment != null) { return segment; } if (!hasRemainingCapacity()) { return null; } segment = MemorySegmentFactory.allocateUnpooledSegment(PAGE_SIZE); totalAllocatedMemory += PAGE_SIZE; return segment; } MemorySegmentPool(long inMemoryBufferSize); @Nullable @Override MemorySegment nextSegment();  }