Top Description Fields Constructors Methods
io.netty5.channel

public Class MultithreadEventLoopGroup

extends MultithreadEventExecutorGroup
implements EventLoopGroup
Class Inheritance
All Implemented Interfaces
io.netty5.channel.EventLoopGroup, io.netty5.util.concurrent.EventExecutorGroup, java.util.concurrent.Executor, java.lang.Iterable
Imports
io.netty5.util.NettyRuntime, io.netty5.util.concurrent.DefaultThreadFactory, .MultithreadEventExecutorGroup, .RejectedExecutionHandler, .RejectedExecutionHandlers, .ThreadPerTaskExecutor, io.netty5.util.internal.EmptyArrays, .SystemPropertyUtil, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.util.ArrayList, .Arrays, .Collections, .List, java.util.concurrent.Executor, .ThreadFactory

EventLoopGroup implementation that will handle its tasks with multiple threads.

Field Summary

Modifier and TypeField and Description
public static final int
private static final InternalLogger

Constructor Summary

AccessConstructor and Description
public
MultithreadEventLoopGroup(IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
)

Create a new instance.

public
MultithreadEventLoopGroup(int
the number of threads that will be used by this instance.
nThreads
,
IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
)

Create a new instance.

public
MultithreadEventLoopGroup(int
the number of threads that will be used by this instance.
nThreads
,
Executor
the Executor to use, or null if the default should be used.
executor
,
IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
)

Create a new instance.

public
MultithreadEventLoopGroup(int
the number of threads that will be used by this instance.
nThreads
,
ThreadFactory
the ThreadFactory to use, or null if the default should be used.
threadFactory
,
IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
)

Create a new instance.

public
MultithreadEventLoopGroup(Executor
the Executor to use, or null if the default should be used.
executor
,
IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
)

Create a new instance.

public
MultithreadEventLoopGroup(ThreadFactory
the ThreadFactory to use, or null if the default should be used.
threadFactory
,
IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
)

Create a new instance.

public
MultithreadEventLoopGroup(int
the number of threads that will be used by this instance.
nThreads
,
Executor
the Executor to use, or null if the default should be used.
executor
,
IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
,
int
the maximum number of pending tasks before new tasks will be rejected.
maxPendingTasks
,
RejectedExecutionHandler rejectedHandler)

Create a new instance.

public
MultithreadEventLoopGroup(int
the number of threads that will be used by this instance.
nThreads
,
ThreadFactory
the ThreadFactory to use, or null if the default should be used.
threadFactory
,
IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
,
int
the maximum number of pending tasks before new tasks will be rejected.
maxPendingTasks
,
RejectedExecutionHandler rejectedHandler)

Create a new instance.

public
MultithreadEventLoopGroup(int
the number of threads that will be used by this instance.
nThreads
,
Executor
the Executor to use, or null if the default should be used.
executor
,
IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
,
int
the maximum number of pending tasks before new tasks will be rejected.
maxPendingTasks
,
RejectedExecutionHandler rejectedHandler, int
the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.
maxTasksPerRun
)

Create a new instance.

public
MultithreadEventLoopGroup(int
the number of threads that will be used by this instance.
nThreads
,
ThreadFactory
the ThreadFactory to use, or null if the default should be used.
threadFactory
,
IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
,
int
the maximum number of pending tasks before new tasks will be rejected.
maxPendingTasks
,
RejectedExecutionHandler rejectedHandler, int
the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.
maxTasksPerRun
)

Create a new instance.

protected
MultithreadEventLoopGroup(int
the number of threads that will be used by this instance.
nThreads
,
Executor
the Executor to use, or null if the default should be used.
executor
,
IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
,
int
the maximum number of pending tasks before new tasks will be rejected.
maxPendingTasks
,
RejectedExecutionHandler rejectedHandler, int
the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.
maxTasksPerRun
,
Object... args)

Create a new instance.

protected
MultithreadEventLoopGroup(int
the number of threads that will be used by this instance.
nThreads
,
ThreadFactory
the ThreadFactory to use, or null if the default should be used.
threadFactory
,
IoHandlerFactory
the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
ioHandlerFactory
,
int
the maximum number of pending tasks before new tasks will be rejected.
maxPendingTasks
,
RejectedExecutionHandler rejectedHandler, int
the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.
maxTasksPerRun
,
Object... args)

Create a new instance.

Method Summary

Modifier and TypeMethod and Description
private static Object[]
merge(IoHandlerFactory ioHandlerFactory, int maxTasksPerRun, Object... args)

protected final EventLoop
newChild(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, Object... args)

Overrides io.netty5.util.concurrent.MultithreadEventExecutorGroup.newChild.

Create a new EventExecutor which will later then accessible via the next() method.
protected EventLoop

Returns:

the EventLoop to use.
newChild
(Executor
the Executor to use for execution.
executor
,
int
the maximum number of pending tasks.
maxPendingTasks
,
RejectedExecutionHandler
the RejectedExecutionHandler to use when the number of outstanding tasks reach maxPendingTasks.
rejectedExecutionHandler
,
IoHandler
the IoHandler to use.
ioHandler
,
int
the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.
maxTasksPerRun
,
Object...
any extra args needed to construct the EventLoop. This will be an empty array if not sub-classes and extra arguments are given.
args
)

Creates a new EventLoop to use.

private static ThreadFactory
public final EventLoop
protected static int
pickThreadCount(int nThreads)

Return the number of threads to use based on the given nThreads.

Inherited from io.netty5.util.concurrent.MultithreadEventExecutorGroup:
awaitTerminationexecutorCountexecutorsisShutdownisShuttingDownisTerminatediteratorshutdownGracefullyterminationFuture

Field Detail

DEFAULT_EVENT_LOOP_THREADSback to summary
public static final int DEFAULT_EVENT_LOOP_THREADS
loggerback to summary
private static final InternalLogger logger

Constructor Detail

MultithreadEventLoopGroupback to summary
public MultithreadEventLoopGroup(IoHandlerFactory ioHandlerFactory)

Create a new instance.

Parameters
ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

MultithreadEventLoopGroupback to summary
public MultithreadEventLoopGroup(int nThreads, IoHandlerFactory ioHandlerFactory)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

MultithreadEventLoopGroupback to summary
public MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

executor:Executor

the Executor to use, or null if the default should be used.

ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

MultithreadEventLoopGroupback to summary
public MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

threadFactory:ThreadFactory

the ThreadFactory to use, or null if the default should be used.

ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

MultithreadEventLoopGroupback to summary
public MultithreadEventLoopGroup(Executor executor, IoHandlerFactory ioHandlerFactory)

Create a new instance.

Parameters
executor:Executor

the Executor to use, or null if the default should be used.

ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

MultithreadEventLoopGroupback to summary
public MultithreadEventLoopGroup(ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory)

Create a new instance.

Parameters
threadFactory:ThreadFactory

the ThreadFactory to use, or null if the default should be used.

ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

MultithreadEventLoopGroupback to summary
public MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

executor:Executor

the Executor to use, or null if the default should be used.

ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

maxPendingTasks:int

the maximum number of pending tasks before new tasks will be rejected.

rejectedHandler:RejectedExecutionHandler

the RejectedExecutionHandler to use.

MultithreadEventLoopGroupback to summary
public MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

threadFactory:ThreadFactory

the ThreadFactory to use, or null if the default should be used.

ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

maxPendingTasks:int

the maximum number of pending tasks before new tasks will be rejected.

rejectedHandler:RejectedExecutionHandler

the RejectedExecutionHandler to use.

MultithreadEventLoopGroupback to summary
public MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

executor:Executor

the Executor to use, or null if the default should be used.

ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

maxPendingTasks:int

the maximum number of pending tasks before new tasks will be rejected.

rejectedHandler:RejectedExecutionHandler

the RejectedExecutionHandler to use.

maxTasksPerRun:int

the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.

MultithreadEventLoopGroupback to summary
public MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

threadFactory:ThreadFactory

the ThreadFactory to use, or null if the default should be used.

ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

maxPendingTasks:int

the maximum number of pending tasks before new tasks will be rejected.

rejectedHandler:RejectedExecutionHandler

the RejectedExecutionHandler to use.

maxTasksPerRun:int

the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.

MultithreadEventLoopGroupback to summary
protected MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun, Object... args)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

executor:Executor

the Executor to use, or null if the default should be used.

ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

maxPendingTasks:int

the maximum number of pending tasks before new tasks will be rejected.

rejectedHandler:RejectedExecutionHandler

the RejectedExecutionHandler to use.

maxTasksPerRun:int

the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.

args:Object[]

extra arguments passed to newChild(Executor, int, RejectedExecutionHandler, IoHandler, int, Object...)

MultithreadEventLoopGroupback to summary
protected MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun, Object... args)

Create a new instance.

Parameters
nThreads:int

the number of threads that will be used by this instance.

threadFactory:ThreadFactory

the ThreadFactory to use, or null if the default should be used.

ioHandlerFactory:IoHandlerFactory

the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.

maxPendingTasks:int

the maximum number of pending tasks before new tasks will be rejected.

rejectedHandler:RejectedExecutionHandler

the RejectedExecutionHandler to use.

maxTasksPerRun:int

the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.

args:Object[]

extra arguments passed to newChild(Executor, int, RejectedExecutionHandler, IoHandler, int, Object...)

Method Detail

mergeback to summary
private static Object[] merge(IoHandlerFactory ioHandlerFactory, int maxTasksPerRun, Object... args)
newChildback to summary
protected final EventLoop newChild(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, Object... args)

Overrides io.netty5.util.concurrent.MultithreadEventExecutorGroup.newChild.

Doc from io.netty5.util.concurrent.MultithreadEventExecutorGroup.newChild.

Create a new EventExecutor which will later then accessible via the next() method. This method will be called for each thread that will serve this MultithreadEventExecutorGroup. As this method is called from within the constructor you can only use the parameters passed into the method when overriding this method.

Annotations
@Override
newChildback to summary
protected EventLoop newChild(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, IoHandler ioHandler, int maxTasksPerRun, Object... args)

Creates a new EventLoop to use. As this method is called from within the constructor you can only use the parameters passed into the method when overriding this method.

Parameters
executor:Executor

the Executor to use for execution.

maxPendingTasks:int

the maximum number of pending tasks.

rejectedExecutionHandler:RejectedExecutionHandler

the RejectedExecutionHandler to use when the number of outstanding tasks reach maxPendingTasks.

ioHandler:IoHandler

the IoHandler to use.

maxTasksPerRun:int

the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.

args:Object[]

any extra args needed to construct the EventLoop. This will be an empty array if not sub-classes and extra arguments are given.

Returns:EventLoop

the EventLoop to use.

newDefaultThreadFactoryback to summary
private static ThreadFactory newDefaultThreadFactory()
nextback to summary
public final EventLoop next()

Overrides io.netty5.util.concurrent.MultithreadEventExecutorGroup.next.

Implements io.netty5.channel.EventLoopGroup.next, io.netty5.util.concurrent.EventExecutorGroup.next.

Doc from io.netty5.channel.EventLoopGroup.next.

Return the next EventLoop to use

Annotations
@Override
pickThreadCountback to summary
protected static int pickThreadCount(int nThreads)

Return the number of threads to use based on the given nThreads.