Class MultithreadEventLoopGroup

  • All Implemented Interfaces:
    EventLoopGroup, io.netty5.util.concurrent.EventExecutorGroup, Iterable<io.netty5.util.concurrent.EventExecutor>, Executor

    public class MultithreadEventLoopGroup
    extends io.netty5.util.concurrent.MultithreadEventExecutorGroup
    implements EventLoopGroup
    EventLoopGroup implementation that will handle its tasks with multiple threads.
    • Field Detail

      • DEFAULT_EVENT_LOOP_THREADS

        public static final int DEFAULT_EVENT_LOOP_THREADS
    • Constructor Detail

      • MultithreadEventLoopGroup

        public MultithreadEventLoopGroup​(IoHandlerFactory ioHandlerFactory)
        Create a new instance.
        Parameters:
        ioHandlerFactory - the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
      • 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 - the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
      • 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 - the Executor to use, or null if the default should be used.
        ioHandlerFactory - the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
      • 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 - the ThreadFactory to use, or null if the default should be used.
        ioHandlerFactory - the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
      • MultithreadEventLoopGroup

        public MultithreadEventLoopGroup​(Executor executor,
                                         IoHandlerFactory ioHandlerFactory)
        Create a new instance.
        Parameters:
        executor - the Executor to use, or null if the default should be used.
        ioHandlerFactory - the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
      • MultithreadEventLoopGroup

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

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

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

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

        protected MultithreadEventLoopGroup​(int nThreads,
                                            Executor executor,
                                            IoHandlerFactory ioHandlerFactory,
                                            int maxPendingTasks,
                                            io.netty5.util.concurrent.RejectedExecutionHandler rejectedHandler,
                                            int maxTasksPerRun,
                                            Object... args)
        Create a new instance.
        Parameters:
        nThreads - the number of threads that will be used by this instance.
        executor - the Executor to use, or null if the default should be used.
        ioHandlerFactory - the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
        maxPendingTasks - the maximum number of pending tasks before new tasks will be rejected.
        rejectedHandler - the RejectedExecutionHandler to use.
        maxTasksPerRun - the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.
        args - extra arguments passed to newChild(Executor, int, RejectedExecutionHandler, IoHandler, int, Object...)
      • MultithreadEventLoopGroup

        protected MultithreadEventLoopGroup​(int nThreads,
                                            ThreadFactory threadFactory,
                                            IoHandlerFactory ioHandlerFactory,
                                            int maxPendingTasks,
                                            io.netty5.util.concurrent.RejectedExecutionHandler rejectedHandler,
                                            int maxTasksPerRun,
                                            Object... args)
        Create a new instance.
        Parameters:
        nThreads - the number of threads that will be used by this instance.
        threadFactory - the ThreadFactory to use, or null if the default should be used.
        ioHandlerFactory - the IoHandlerFactory to use for creating new IoHandler instances that will handle the IO for the EventLoop.
        maxPendingTasks - the maximum number of pending tasks before new tasks will be rejected.
        rejectedHandler - the RejectedExecutionHandler to use.
        maxTasksPerRun - the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.
        args - extra arguments passed to newChild(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 given nThreads.
      • next

        public final EventLoop next()
        Description copied from interface: EventLoopGroup
        Return the next EventLoop to use
        Specified by:
        next in interface io.netty5.util.concurrent.EventExecutorGroup
        Specified by:
        next in interface EventLoopGroup
        Overrides:
        next in class io.netty5.util.concurrent.MultithreadEventExecutorGroup
      • newChild

        protected final EventLoop newChild​(Executor executor,
                                           int maxPendingTasks,
                                           io.netty5.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler,
                                           Object... args)
        Overrides:
        newChild in class io.netty5.util.concurrent.MultithreadEventExecutorGroup
      • newChild

        protected EventLoop newChild​(Executor executor,
                                     int maxPendingTasks,
                                     io.netty5.util.concurrent.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 - the Executor to use for execution.
        maxPendingTasks - the maximum number of pending tasks.
        rejectedExecutionHandler - the RejectedExecutionHandler to use when the number of outstanding tasks reach maxPendingTasks.
        ioHandler - the IoHandler to use.
        maxTasksPerRun - the maximum number of tasks per EventLoop run that will be processed before trying to handle IO again.
        args - any extra args needed to construct the EventLoop. This will be an empty array if not sub-classes and extra arguments are given.
        Returns:
        the EventLoop to use.