From 003c8cc7abcfbe0c7a3ce97a23413ba4c336034a Mon Sep 17 00:00:00 2001 From: Carl Mastrangelo Date: Wed, 20 Sep 2017 14:57:28 -0700 Subject: [PATCH] Expose all defaults on PooledByteBufAllocator Motivation: Most, but not all defaults are statically exposed on PooledByteBufAllocator. This makes it cumbersome to make a custom allocator where most of the defaults remain the same. Modification: Expose useCacheForAllThreads, and Direct preferred. The latter is needed because it is under the internal package, and public code should probably not depend on it. Result: More customizeable allocators --- .../io/netty/buffer/PooledByteBufAllocator.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java b/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java index 6e9c06cc80..d5ce4e183f 100644 --- a/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java +++ b/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java @@ -359,6 +359,20 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator implements return DEFAULT_MAX_ORDER; } + /** + * Default thread caching behavior - System Property: io.netty.allocator.useCacheForAllThreads - default true + */ + public static boolean defaultUseCacheForAllThreads() { + return DEFAULT_USE_CACHE_FOR_ALL_THREADS; + } + + /** + * Default prefer direct - System Property: io.netty.noPreferDirect - default false + */ + public static boolean defaultPreferDirect() { + return PlatformDependent.directBufferPreferred(); + } + /** * Default tiny cache size - System Property: io.netty.allocator.tinyCacheSize - default 512 */