@ApiStatus.Internal public final class Platform extends Object
| Modifier and Type | Field and Description |
|---|---|
static ThreadGroup |
DEFAULT_THREAD_GROUP |
| Modifier and Type | Method and Description |
|---|---|
static io.netty.channel.EventLoopGroup |
createEventLoopGroup(Class<? extends io.netty.channel.Channel> channelClass,
Executor executor,
int nThreads)
Creates a new
EventLoopGroup instance. |
static io.netty.channel.EventLoopGroup |
createEventLoopGroup(ExecutorService executor,
int nThreads,
boolean useNative)
Creates a new
EventLoopGroup instance. |
static ThreadGroup |
createThreadGroup(Class<?> cls)
creeateThreadGroup.
|
static ThreadGroup |
createThreadGroup(Class<?> cls,
ThreadGroup parent)
creeateThreadGroup.
|
static Class<? extends io.netty.channel.Channel> |
getChannelClass(TransportType type)
Retrieves the channel class based on the detected platform
|
static Class<? extends io.netty.channel.Channel> |
getChannelClass(TransportType type,
boolean useNativeTransport)
Retrieves the channel class based on the detected platform
|
static Class<? extends io.netty.channel.Channel> |
getChannelClass(TransportType type,
io.netty.channel.EventLoopGroup group)
Retrieves the channel class based on the provided
EventLoopGroup. |
static Integer |
getCoreThreadCount(Options options,
ExecutorService executorService)
Get the core number of threads specified in
Options if available. |
static io.netty.channel.EventLoopGroup |
getDefaultEventLoopGroup()
The global
EventLoopGroup shared across all clients by default. |
static ExecutorService |
getDefaultExecutor()
The global
ExecutorService used by all clients by default. |
static BlockingQueue<Runnable> |
getDefaultQueue()
getDefaultQueue.
|
static ThreadFactory |
getDefaultThreadFactory()
getDefaultThreadFactory.
|
static io.netty.channel.EventLoopGroup |
getOrCreateEventLoopGroup(Class<? extends io.netty.channel.Channel> channelClass,
ExecutorService executor,
int nThreads) |
static io.netty.channel.EventLoopGroup |
getOrCreateEventLoopGroup(ExecutorService executor,
int nThreads,
boolean useNative) |
static void |
initialize()
Initialize platform and properties.
|
static boolean |
isDefaultExecutor(Executor executor)
Check if the specified
Executor is a shared global executor provided by the library |
public static final ThreadGroup DEFAULT_THREAD_GROUP
public static void initialize()
Initialize platform and properties. This can only be called once.
public static ExecutorService getDefaultExecutor()
The global ExecutorService used by all clients by default. (For internal use only, use at your own risk)
ExecutorServicepublic static BlockingQueue<Runnable> getDefaultQueue()
getDefaultQueue.
BlockingQueue objectpublic static ThreadFactory getDefaultThreadFactory()
getDefaultThreadFactory.
ThreadFactory used by this librarypublic static boolean isDefaultExecutor(Executor executor)
Executor is a shared global executor provided by the librarypublic static Integer getCoreThreadCount(Options options, ExecutorService executorService)
Options if available. If not specified in options, it will attempt to detect it via heuristics.options - The Options instance to be used as lookupexecutorService - The ExecutorService to be used for reference in-case value is not specified in the provided OptionsEventLoopGroupIllegalStateException - If the number of core threads could not be determined.public static io.netty.channel.EventLoopGroup getDefaultEventLoopGroup()
EventLoopGroup shared across all clients by default. Upon shutdown, the default executor will also be automatically closed.EventLoopGrouppublic static io.netty.channel.EventLoopGroup createEventLoopGroup(ExecutorService executor, int nThreads, boolean useNative)
EventLoopGroup instance. The default is NioEventLoopGroupexecutor - The Executor to be used by the EventLoopGroupnThreads - The number of threads to be used by the EventLoopGroup. If a custom Executor is provided, then the value should be less than or equals to the maximum number of threads supported by the provided Executor. Set to 0 to use the value defined in system property -Dio.netty.eventLoopThreads (if present) or the default value defined by netty (num of processors x 2).useNative - true to use native transports when available (e.g. epoll for linux, kqueue for osx).EventLoopGroup instancepublic static io.netty.channel.EventLoopGroup createEventLoopGroup(Class<? extends io.netty.channel.Channel> channelClass, Executor executor, int nThreads)
EventLoopGroup instance. The default is NioEventLoopGroupchannelClass - The netty channel Class that will be used as a referece to lookup the EventLoopGroupexecutor - The Executor to be used by the EventLoopGroupnThreads - The number of threads to be used by the EventLoopGroup. If a custom Executor is provided, then the value should be less than or equals to the maximum number of threads supported by the provided Executor. Set to 0 to use the value defined in system property -Dio.netty.eventLoopThreads (if present) or the default value defined by netty (num of processors x 2).EventLoopGroup instanceIllegalStateException - If channelClass is not supportedIllegalArgumentException - If channelClass is nullpublic static io.netty.channel.EventLoopGroup getOrCreateEventLoopGroup(Class<? extends io.netty.channel.Channel> channelClass, ExecutorService executor, int nThreads)
public static io.netty.channel.EventLoopGroup getOrCreateEventLoopGroup(ExecutorService executor, int nThreads, boolean useNative)
public static ThreadGroup createThreadGroup(Class<?> cls)
creeateThreadGroup.
cls - a Class objectThreadGroup objectpublic static ThreadGroup createThreadGroup(Class<?> cls, ThreadGroup parent)
creeateThreadGroup.
cls - a Class objectparent - a ThreadGroup objectThreadGroup objectpublic static Class<? extends io.netty.channel.Channel> getChannelClass(TransportType type, io.netty.channel.EventLoopGroup group)
Retrieves the channel class based on the provided EventLoopGroup.
type - a TransportType objectgroup - a EventLoopGroup objectClass objectpublic static Class<? extends io.netty.channel.Channel> getChannelClass(TransportType type)
Retrieves the channel class based on the detected platform
type - a TransportTypeClass objectpublic static Class<? extends io.netty.channel.Channel> getChannelClass(TransportType type, boolean useNativeTransport)
Retrieves the channel class based on the detected platform
type - a TransportType objectuseNativeTransport - true to use native transportClass objectCopyright © 2016–2024. All rights reserved.