- java.lang.Object
-
- io.netty5.util.concurrent.MultithreadEventExecutorGroup
-
- io.netty5.channel.MultithreadEventLoopGroup
-
- All Implemented Interfaces:
EventLoopGroup
,EventExecutorGroup
,Iterable<EventExecutor>
,Executor
public class MultithreadEventLoopGroup extends MultithreadEventExecutorGroup implements EventLoopGroup
EventLoopGroup
implementation that will handle its tasks with multiple threads.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_EVENT_LOOP_THREADS
-
Constructor Summary
Constructors Modifier Constructor Description MultithreadEventLoopGroup(int nThreads, IoHandlerFactory ioHandlerFactory)
Create a new instance.MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory)
Create a new instance.MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler)
Create a new instance.MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun)
Create a new instance.protected
MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun, Object... args)
Create a new instance.MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory)
Create a new instance.MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler)
Create a new instance.MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun)
Create a new instance.protected
MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun, Object... args)
Create a new instance.MultithreadEventLoopGroup(IoHandlerFactory ioHandlerFactory)
Create a new instance.MultithreadEventLoopGroup(Executor executor, IoHandlerFactory ioHandlerFactory)
Create a new instance.MultithreadEventLoopGroup(ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory)
Create a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected EventLoop
newChild(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, IoHandler ioHandler, int maxTasksPerRun, Object... args)
Creates a newEventLoop
to use.protected EventLoop
newChild(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, Object... args)
Create a new EventExecutor which will later then accessible via theMultithreadEventExecutorGroup.next()
method.EventLoop
next()
Returns the nextEventExecutor
to use.protected static int
pickThreadCount(int nThreads)
Return the number of threads to use based on the givennThreads
.-
Methods inherited from class io.netty5.util.concurrent.MultithreadEventExecutorGroup
awaitTermination, executorCount, executors, isShutdown, isShuttingDown, isTerminated, iterator, shutdownGracefully, terminationFuture
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.util.concurrent.EventExecutorGroup
awaitTermination, execute, isShutdown, isShuttingDown, isTerminated, iterator, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdownGracefully, shutdownGracefully, submit, submit, submit, terminationFuture
-
Methods inherited from interface io.netty5.channel.EventLoopGroup
isCompatible
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(IoHandlerFactory ioHandlerFactory)
Create a new instance.- Parameters:
ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(int nThreads, IoHandlerFactory ioHandlerFactory)
Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory)
Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.executor
- theExecutor
to use, ornull
if the default should be used.ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory)
Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.threadFactory
- theThreadFactory
to use, ornull
if the default should be used.ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(Executor executor, IoHandlerFactory ioHandlerFactory)
Create a new instance.- Parameters:
executor
- theExecutor
to use, ornull
if the default should be used.ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory)
Create a new instance.- Parameters:
threadFactory
- theThreadFactory
to use, ornull
if the default should be used.ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler)
Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.executor
- theExecutor
to use, ornull
if the default should be used.ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.maxPendingTasks
- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler
- theRejectedExecutionHandler
to use.
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler)
Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.threadFactory
- theThreadFactory
to use, ornull
if the default should be used.ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.maxPendingTasks
- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler
- theRejectedExecutionHandler
to use.
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun)
Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.executor
- theExecutor
to use, ornull
if the default should be used.ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.maxPendingTasks
- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler
- theRejectedExecutionHandler
to use.maxTasksPerRun
- the maximum number of tasks perEventLoop
run that will be processed before trying to handle IO again.
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun)
Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.threadFactory
- theThreadFactory
to use, ornull
if the default should be used.ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.maxPendingTasks
- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler
- theRejectedExecutionHandler
to use.maxTasksPerRun
- the maximum number of tasks perEventLoop
run that will be processed before trying to handle IO again.
-
MultithreadEventLoopGroup
protected MultithreadEventLoopGroup(int nThreads, Executor executor, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun, Object... args)
Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.executor
- theExecutor
to use, ornull
if the default should be used.ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.maxPendingTasks
- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler
- theRejectedExecutionHandler
to use.maxTasksPerRun
- the maximum number of tasks perEventLoop
run that will be processed before trying to handle IO again.args
- extra arguments passed tonewChild(Executor, int, RejectedExecutionHandler, IoHandler, int, Object...)
-
MultithreadEventLoopGroup
protected MultithreadEventLoopGroup(int nThreads, ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory, int maxPendingTasks, RejectedExecutionHandler rejectedHandler, int maxTasksPerRun, Object... args)
Create a new instance.- Parameters:
nThreads
- the number of threads that will be used by this instance.threadFactory
- theThreadFactory
to use, ornull
if the default should be used.ioHandlerFactory
- theIoHandlerFactory
to use for creating newIoHandler
instances that will handle the IO for theEventLoop
.maxPendingTasks
- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler
- theRejectedExecutionHandler
to use.maxTasksPerRun
- the maximum number of tasks perEventLoop
run that will be processed before trying to handle IO again.args
- extra arguments passed tonewChild(Executor, int, RejectedExecutionHandler, IoHandler, int, Object...)
-
-
Method Detail
-
pickThreadCount
protected static int pickThreadCount(int nThreads)
Return the number of threads to use based on the givennThreads
.
-
next
public final EventLoop next()
Description copied from class:MultithreadEventExecutorGroup
Returns the nextEventExecutor
to use. The default implementation will use round-robin, but you may override this to change the selection algorithm.- Specified by:
next
in interfaceEventExecutorGroup
- Specified by:
next
in interfaceEventLoopGroup
- Overrides:
next
in classMultithreadEventExecutorGroup
-
newChild
protected final EventLoop newChild(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, Object... args)
Description copied from class:MultithreadEventExecutorGroup
Create a new EventExecutor which will later then accessible via theMultithreadEventExecutorGroup.next()
method. This method will be called for each thread that will serve thisMultithreadEventExecutorGroup
. As this method is called from within the constructor you can only use the parameters passed into the method when overriding this method.- Overrides:
newChild
in classMultithreadEventExecutorGroup
-
newChild
protected EventLoop newChild(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, IoHandler ioHandler, int maxTasksPerRun, Object... args)
Creates a newEventLoop
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
- theExecutor
to use for execution.maxPendingTasks
- the maximum number of pending tasks.rejectedExecutionHandler
- theRejectedExecutionHandler
to use when the number of outstanding tasks reachmaxPendingTasks
.ioHandler
- theIoHandler
to use.maxTasksPerRun
- the maximum number of tasks perEventLoop
run that will be processed before trying to handle IO again.args
- any extra args needed to construct theEventLoop
. This will be an empty array if not sub-classes and extra arguments are given.- Returns:
- the
EventLoop
to use.
-
-