FreeListManager { boolean okToReuse(Slab[] newSlabs) { return newSlabs == null || newSlabs == this.slabs; } FreeListManager(MemoryAllocatorImpl ma, final Slab[] slabs); long getUsedMemory(); long getFreeMemory(); @SuppressWarnings("synthetic-access") OffHeapStoredObject allocate(int size); @SuppressWarnings("synthetic-access") void free(long addr); static final int TINY_MULTIPLE; static final int TINY_FREE_LIST_COUNT; static final int HUGE_MULTIPLE; static final int MAX_TINY; }
@Test public void okToReuseNull() { setUpSingleSlabManager(); assertThat(this.freeListManager.okToReuse(null)).isTrue(); }
@Test public void okToReuseSameSlabs() { Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE); Slab[] slabs = new Slab[] {slab}; this.freeListManager = createFreeListManager(ma, slabs); assertThat(this.freeListManager.okToReuse(slabs)).isTrue(); }
@Test public void notOkToReuseDifferentSlabs() { Slab slab = new SlabImpl(DEFAULT_SLAB_SIZE); Slab[] slabs = new Slab[] {slab}; this.freeListManager = createFreeListManager(ma, slabs); Slab[] slabs2 = new Slab[] {slab}; assertThat(this.freeListManager.okToReuse(slabs2)).isFalse(); }