@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)
ExecutorService
public 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 Options
EventLoopGroup
IllegalStateException
- 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.EventLoopGroup
public static io.netty.channel.EventLoopGroup createEventLoopGroup(ExecutorService executor, int nThreads, boolean useNative)
EventLoopGroup
instance. The default is NioEventLoopGroup
executor
- The Executor
to be used by the EventLoopGroup
nThreads
- 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 NioEventLoopGroup
channelClass
- The netty channel Class
that will be used as a referece to lookup the EventLoopGroup
executor
- The Executor
to be used by the EventLoopGroup
nThreads
- 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 null
public 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 TransportType
Class
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.