|
14 | 14 | */ |
15 | 15 | package io.netty5.buffer; |
16 | 16 |
|
| 17 | +import io.netty5.buffer.adapt.AdaptablePoolingAllocator; |
17 | 18 | import io.netty5.util.internal.PlatformDependent; |
18 | 19 | import io.netty5.util.internal.SystemPropertyUtil; |
19 | 20 | import io.netty5.util.internal.logging.InternalLogger; |
@@ -44,22 +45,25 @@ public final class DefaultBufferAllocators { |
44 | 45 | "io.netty5.allocator.type", PlatformDependent.isAndroid() ? "unpooled" : "pooled"); |
45 | 46 | allocType = allocType.toLowerCase(Locale.US).trim(); |
46 | 47 | boolean directBufferPreferred = directBufferPreferred(); |
| 48 | + String allocTypeForLogging = allocType; |
47 | 49 |
|
48 | 50 | final BufferAllocator onHeap; |
49 | 51 | final BufferAllocator offHeap; |
50 | 52 | if ("unpooled".equals(allocType)) { |
51 | 53 | onHeap = BufferAllocator.onHeapUnpooled(); |
52 | 54 | offHeap = BufferAllocator.offHeapUnpooled(); |
53 | | - logger.debug("-Dio.netty5.allocator.type: {}", allocType); |
54 | 55 | } else if ("pooled".equals(allocType)) { |
55 | 56 | onHeap = BufferAllocator.onHeapPooled(); |
56 | 57 | offHeap = BufferAllocator.offHeapPooled(); |
57 | | - logger.debug("-Dio.netty5.allocator.type: {}", allocType); |
| 58 | + } else if ("adaptive".equals(allocType)) { |
| 59 | + onHeap = new AdaptablePoolingAllocator(false); |
| 60 | + offHeap = new AdaptablePoolingAllocator(true); |
58 | 61 | } else { |
59 | 62 | onHeap = BufferAllocator.onHeapPooled(); |
60 | 63 | offHeap = BufferAllocator.offHeapPooled(); |
61 | | - logger.debug("-Dio.netty5.allocator.type: pooled (unknown: {})", allocType); |
| 64 | + allocTypeForLogging = "pooled (unknown: " + allocType + ')'; |
62 | 65 | } |
| 66 | + logger.debug("-Dio.netty5.allocator.type: {}", allocTypeForLogging); |
63 | 67 | UncloseableBufferAllocator onHeapUnclosable = new UncloseableBufferAllocator(onHeap); |
64 | 68 | UncloseableBufferAllocator offHeapUnclosable = new UncloseableBufferAllocator(offHeap); |
65 | 69 | DEFAULT_PREFERRED_ALLOCATOR = directBufferPreferred? offHeapUnclosable : onHeapUnclosable; |
|