- 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
EventLoopGroupimplementation that will handle its tasks with multiple threads.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_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.protectedMultithreadEventLoopGroup(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.protectedMultithreadEventLoopGroup(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 EventLoopnewChild(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, IoHandler ioHandler, int maxTasksPerRun, Object... args)Creates a newEventLoopto use.protected EventLoopnewChild(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, Object... args)Create a new EventExecutor which will later then accessible via theMultithreadEventExecutorGroup.next()method.EventLoopnext()Returns the nextEventExecutorto use.protected static intpickThreadCount(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- theIoHandlerFactoryto use for creating newIoHandlerinstances 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- theIoHandlerFactoryto use for creating newIoHandlerinstances 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- theExecutorto use, ornullif the default should be used.ioHandlerFactory- theIoHandlerFactoryto use for creating newIoHandlerinstances 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- theThreadFactoryto use, ornullif the default should be used.ioHandlerFactory- theIoHandlerFactoryto use for creating newIoHandlerinstances that will handle the IO for theEventLoop.
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(Executor executor, IoHandlerFactory ioHandlerFactory)
Create a new instance.- Parameters:
executor- theExecutorto use, ornullif the default should be used.ioHandlerFactory- theIoHandlerFactoryto use for creating newIoHandlerinstances that will handle the IO for theEventLoop.
-
MultithreadEventLoopGroup
public MultithreadEventLoopGroup(ThreadFactory threadFactory, IoHandlerFactory ioHandlerFactory)
Create a new instance.- Parameters:
threadFactory- theThreadFactoryto use, ornullif the default should be used.ioHandlerFactory- theIoHandlerFactoryto use for creating newIoHandlerinstances 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- theExecutorto use, ornullif the default should be used.ioHandlerFactory- theIoHandlerFactoryto use for creating newIoHandlerinstances that will handle the IO for theEventLoop.maxPendingTasks- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler- theRejectedExecutionHandlerto 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- theThreadFactoryto use, ornullif the default should be used.ioHandlerFactory- theIoHandlerFactoryto use for creating newIoHandlerinstances that will handle the IO for theEventLoop.maxPendingTasks- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler- theRejectedExecutionHandlerto 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- theExecutorto use, ornullif the default should be used.ioHandlerFactory- theIoHandlerFactoryto use for creating newIoHandlerinstances that will handle the IO for theEventLoop.maxPendingTasks- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler- theRejectedExecutionHandlerto use.maxTasksPerRun- the maximum number of tasks perEventLooprun 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- theThreadFactoryto use, ornullif the default should be used.ioHandlerFactory- theIoHandlerFactoryto use for creating newIoHandlerinstances that will handle the IO for theEventLoop.maxPendingTasks- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler- theRejectedExecutionHandlerto use.maxTasksPerRun- the maximum number of tasks perEventLooprun 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- theExecutorto use, ornullif the default should be used.ioHandlerFactory- theIoHandlerFactoryto use for creating newIoHandlerinstances that will handle the IO for theEventLoop.maxPendingTasks- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler- theRejectedExecutionHandlerto use.maxTasksPerRun- the maximum number of tasks perEventLooprun 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- theThreadFactoryto use, ornullif the default should be used.ioHandlerFactory- theIoHandlerFactoryto use for creating newIoHandlerinstances that will handle the IO for theEventLoop.maxPendingTasks- the maximum number of pending tasks before new tasks will be rejected.rejectedHandler- theRejectedExecutionHandlerto use.maxTasksPerRun- the maximum number of tasks perEventLooprun 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:MultithreadEventExecutorGroupReturns the nextEventExecutorto use. The default implementation will use round-robin, but you may override this to change the selection algorithm.- Specified by:
nextin interfaceEventExecutorGroup- Specified by:
nextin interfaceEventLoopGroup- Overrides:
nextin classMultithreadEventExecutorGroup
-
newChild
protected final EventLoop newChild(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, Object... args)
Description copied from class:MultithreadEventExecutorGroupCreate 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:
newChildin classMultithreadEventExecutorGroup
-
newChild
protected EventLoop newChild(Executor executor, int maxPendingTasks, RejectedExecutionHandler rejectedExecutionHandler, IoHandler ioHandler, int maxTasksPerRun, Object... args)
Creates a newEventLoopto 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- theExecutorto use for execution.maxPendingTasks- the maximum number of pending tasks.rejectedExecutionHandler- theRejectedExecutionHandlerto use when the number of outstanding tasks reachmaxPendingTasks.ioHandler- theIoHandlerto use.maxTasksPerRun- the maximum number of tasks perEventLooprun 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
EventLoopto use.
-
-