Expose the chunkSize used by PooledByteBufAllocator.

Motivation:

Sometimes it may be useful to know the used chunkSize.

Modifications:

Add method to expose chunkSize.

Result:

More exposed details.
This commit is contained in:
Norman Maurer 2017-02-03 20:07:39 +01:00
parent 371c0ca0f8
commit f09a721d7f
1 changed files with 9 additions and 1 deletions

View File

@ -146,6 +146,7 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator {
private final List<PoolArenaMetric> heapArenaMetrics;
private final List<PoolArenaMetric> directArenaMetrics;
private final PoolThreadLocalCache threadCache;
private final int chunkSize;
public PooledByteBufAllocator() {
this(false);
@ -199,7 +200,7 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator {
this.tinyCacheSize = tinyCacheSize;
this.smallCacheSize = smallCacheSize;
this.normalCacheSize = normalCacheSize;
final int chunkSize = validateAndCalculateChunkSize(pageSize, maxOrder);
chunkSize = validateAndCalculateChunkSize(pageSize, maxOrder);
if (nHeapArena < 0) {
throw new IllegalArgumentException("nHeapArena: " + nHeapArena + " (expected: >= 0)");
@ -511,6 +512,13 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator {
return normalCacheSize;
}
/**
* Return the chunk size for an arena.
*/
public final int chunkSize() {
return chunkSize;
}
final PoolThreadCache threadCache() {
return threadCache.get();
}