@Test(timeout = 3000) public void testNumThreadCachesWithNoDirectArenas() throws InterruptedException { int numHeapArenas = 1; final PooledByteBufAllocator allocator = new PooledByteBufAllocator(numHeapArenas, 0, 8192, 1); CountDownLatch tcache0 = createNewThreadCache(allocator); assertEquals(1, allocator.numThreadLocalCaches()); CountDownLatch tcache1 = createNewThreadCache(allocator); assertEquals(2, allocator.numThreadLocalCaches()); destroyThreadCache(tcache0); assertEquals(1, allocator.numThreadLocalCaches()); destroyThreadCache(tcache1); assertEquals(0, allocator.numThreadLocalCaches()); }
public int numThreadLocalCaches() { PoolArena<?>[] arenas = heapArenas != null ? heapArenas : directArenas; if (arenas == null) { return 0; } int total = 0; for (int i = 0; i < arenas.length; i++) { total += arenas[i].numThreadCaches.get(); } return total; }
PooledByteBufAllocator extends AbstractByteBufAllocator { public int numThreadLocalCaches() { PoolArena<?>[] arenas = heapArenas != null ? heapArenas : directArenas; if (arenas == null) { return 0; } int total = 0; for (int i = 0; i < arenas.length; i++) { total += arenas[i].numThreadCaches.get(); } return total; } }
PooledByteBufAllocator extends AbstractByteBufAllocator { public int numThreadLocalCaches() { PoolArena<?>[] arenas = heapArenas != null ? heapArenas : directArenas; if (arenas == null) { return 0; } int total = 0; for (int i = 0; i < arenas.length; i++) { total += arenas[i].numThreadCaches.get(); } return total; } PooledByteBufAllocator();  PooledByteBufAllocator(boolean preferDirect);  PooledByteBufAllocator(int nHeapArena, int nDirectArena, int pageSize, int maxOrder);  PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder);  PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder,
                                  int tinyCacheSize, int smallCacheSize, int normalCacheSize); }
PooledByteBufAllocator extends AbstractByteBufAllocator { public int numThreadLocalCaches() { PoolArena<?>[] arenas = heapArenas != null ? heapArenas : directArenas; if (arenas == null) { return 0; } int total = 0; for (int i = 0; i < arenas.length; i++) { total += arenas[i].numThreadCaches.get(); } return total; } PooledByteBufAllocator();  PooledByteBufAllocator(boolean preferDirect);  PooledByteBufAllocator(int nHeapArena, int nDirectArena, int pageSize, int maxOrder);  PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder);  PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder,
                                  int tinyCacheSize, int smallCacheSize, int normalCacheSize); static int defaultNumHeapArena(); static int defaultNumDirectArena(); static int defaultPageSize(); static int defaultMaxOrder(); static int defaultTinyCacheSize(); static int defaultSmallCacheSize(); static int defaultNormalCacheSize(); @Override boolean isDirectBufferPooled(); @Deprecated boolean hasThreadLocalCache(); @Deprecated void freeThreadLocalCache(); int numHeapArenas(); int numDirectArenas(); List<PoolArenaMetric> heapArenas(); List<PoolArenaMetric> directArenas(); int numThreadLocalCaches(); int tinyCacheSize(); int smallCacheSize(); int normalCacheSize(); String dumpStats(); }
PooledByteBufAllocator extends AbstractByteBufAllocator { public int numThreadLocalCaches() { PoolArena<?>[] arenas = heapArenas != null ? heapArenas : directArenas; if (arenas == null) { return 0; } int total = 0; for (int i = 0; i < arenas.length; i++) { total += arenas[i].numThreadCaches.get(); } return total; } PooledByteBufAllocator();  PooledByteBufAllocator(boolean preferDirect);  PooledByteBufAllocator(int nHeapArena, int nDirectArena, int pageSize, int maxOrder);  PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder);  PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder,
                                  int tinyCacheSize, int smallCacheSize, int normalCacheSize); static int defaultNumHeapArena(); static int defaultNumDirectArena(); static int defaultPageSize(); static int defaultMaxOrder(); static int defaultTinyCacheSize(); static int defaultSmallCacheSize(); static int defaultNormalCacheSize(); @Override boolean isDirectBufferPooled(); @Deprecated boolean hasThreadLocalCache(); @Deprecated void freeThreadLocalCache(); int numHeapArenas(); int numDirectArenas(); List<PoolArenaMetric> heapArenas(); List<PoolArenaMetric> directArenas(); int numThreadLocalCaches(); int tinyCacheSize(); int smallCacheSize(); int normalCacheSize(); String dumpStats(); static final PooledByteBufAllocator DEFAULT; }