Package io.netty.channel.nio
Class NioEventLoopGroup
- java.lang.Object
-
- io.netty.util.concurrent.AbstractEventExecutorGroup
-
- io.netty.util.concurrent.MultithreadEventExecutorGroup
-
- io.netty.channel.MultithreadEventLoopGroup
-
- io.netty.channel.nio.NioEventLoopGroup
-
- All Implemented Interfaces:
EventLoopGroup
,EventExecutorGroup
,java.lang.Iterable<EventExecutor>
,java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
,java.util.concurrent.ScheduledExecutorService
public class NioEventLoopGroup extends MultithreadEventLoopGroup
-
-
Constructor Summary
Constructors Constructor Description NioEventLoopGroup()
Create a new instance using the default number of threads, the defaultThreadFactory
and theSelectorProvider
which is returned bySelectorProvider.provider()
.NioEventLoopGroup(int nThreads)
Create a new instance using the specified number of threads,ThreadFactory
and theSelectorProvider
which is returned bySelectorProvider.provider()
.NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor)
NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, EventExecutorChooserFactory chooserFactory, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory)
NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, EventExecutorChooserFactory chooserFactory, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory, RejectedExecutionHandler rejectedExecutionHandler)
NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, EventExecutorChooserFactory chooserFactory, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory, RejectedExecutionHandler rejectedExecutionHandler, EventLoopTaskQueueFactory taskQueueFactory)
NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, EventExecutorChooserFactory chooserFactory, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory, RejectedExecutionHandler rejectedExecutionHandler, EventLoopTaskQueueFactory taskQueueFactory, EventLoopTaskQueueFactory tailTaskQueueFactory)
NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, java.nio.channels.spi.SelectorProvider selectorProvider)
NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory)
NioEventLoopGroup(int nThreads, java.util.concurrent.ThreadFactory threadFactory)
Create a new instance using the specified number of threads, the givenThreadFactory
and theSelectorProvider
which is returned bySelectorProvider.provider()
.NioEventLoopGroup(int nThreads, java.util.concurrent.ThreadFactory threadFactory, java.nio.channels.spi.SelectorProvider selectorProvider)
Create a new instance using the specified number of threads, the givenThreadFactory
and the givenSelectorProvider
.NioEventLoopGroup(int nThreads, java.util.concurrent.ThreadFactory threadFactory, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory)
NioEventLoopGroup(java.util.concurrent.ThreadFactory threadFactory)
Create a new instance using the default number of threads, the givenThreadFactory
and theSelectorProvider
which is returned bySelectorProvider.provider()
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected EventLoop
newChild(java.util.concurrent.Executor executor, java.lang.Object... args)
Create a new EventExecutor which will later then accessible via theMultithreadEventExecutorGroup.next()
method.void
rebuildSelectors()
Replaces the currentSelector
s of the child event loops with newly createdSelector
s to work around the infamous epoll 100% CPU bug.void
setIoRatio(int ioRatio)
Sets the percentage of the desired amount of time spent for I/O in the child event loops.-
Methods inherited from class io.netty.channel.MultithreadEventLoopGroup
newDefaultThreadFactory, next, register, register, register
-
Methods inherited from class io.netty.util.concurrent.MultithreadEventExecutorGroup
awaitTermination, executorCount, isShutdown, isShuttingDown, isTerminated, iterator, shutdown, shutdownGracefully, terminationFuture
-
Methods inherited from class io.netty.util.concurrent.AbstractEventExecutorGroup
execute, invokeAll, invokeAll, invokeAny, invokeAny, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdownGracefully, shutdownNow, submit, submit, submit
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.util.concurrent.EventExecutorGroup
isShuttingDown, iterator, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, shutdown, shutdownGracefully, shutdownGracefully, shutdownNow, submit, submit, submit, terminationFuture
-
-
-
-
Constructor Detail
-
NioEventLoopGroup
public NioEventLoopGroup()
Create a new instance using the default number of threads, the defaultThreadFactory
and theSelectorProvider
which is returned bySelectorProvider.provider()
.
-
NioEventLoopGroup
public NioEventLoopGroup(int nThreads)
Create a new instance using the specified number of threads,ThreadFactory
and theSelectorProvider
which is returned bySelectorProvider.provider()
.
-
NioEventLoopGroup
public NioEventLoopGroup(java.util.concurrent.ThreadFactory threadFactory)
Create a new instance using the default number of threads, the givenThreadFactory
and theSelectorProvider
which is returned bySelectorProvider.provider()
.
-
NioEventLoopGroup
public NioEventLoopGroup(int nThreads, java.util.concurrent.ThreadFactory threadFactory)
Create a new instance using the specified number of threads, the givenThreadFactory
and theSelectorProvider
which is returned bySelectorProvider.provider()
.
-
NioEventLoopGroup
public NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor)
-
NioEventLoopGroup
public NioEventLoopGroup(int nThreads, java.util.concurrent.ThreadFactory threadFactory, java.nio.channels.spi.SelectorProvider selectorProvider)
Create a new instance using the specified number of threads, the givenThreadFactory
and the givenSelectorProvider
.
-
NioEventLoopGroup
public NioEventLoopGroup(int nThreads, java.util.concurrent.ThreadFactory threadFactory, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory)
-
NioEventLoopGroup
public NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, java.nio.channels.spi.SelectorProvider selectorProvider)
-
NioEventLoopGroup
public NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory)
-
NioEventLoopGroup
public NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, EventExecutorChooserFactory chooserFactory, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory)
-
NioEventLoopGroup
public NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, EventExecutorChooserFactory chooserFactory, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory, RejectedExecutionHandler rejectedExecutionHandler)
-
NioEventLoopGroup
public NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, EventExecutorChooserFactory chooserFactory, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory, RejectedExecutionHandler rejectedExecutionHandler, EventLoopTaskQueueFactory taskQueueFactory)
-
NioEventLoopGroup
public NioEventLoopGroup(int nThreads, java.util.concurrent.Executor executor, EventExecutorChooserFactory chooserFactory, java.nio.channels.spi.SelectorProvider selectorProvider, SelectStrategyFactory selectStrategyFactory, RejectedExecutionHandler rejectedExecutionHandler, EventLoopTaskQueueFactory taskQueueFactory, EventLoopTaskQueueFactory tailTaskQueueFactory)
- Parameters:
nThreads
- the number of threads that will be used by this instance.executor
- the Executor to use, ornull
if default one should be used.chooserFactory
- theEventExecutorChooserFactory
to use.selectorProvider
- theSelectorProvider
to use.selectStrategyFactory
- theSelectStrategyFactory
to use.rejectedExecutionHandler
- theRejectedExecutionHandler
to use.taskQueueFactory
- theEventLoopTaskQueueFactory
to use forSingleThreadEventExecutor.execute(Runnable)
, ornull
if default one should be used.tailTaskQueueFactory
- theEventLoopTaskQueueFactory
to use forSingleThreadEventLoop.executeAfterEventLoopIteration(Runnable)
, ornull
if default one should be used.
-
-
Method Detail
-
setIoRatio
public void setIoRatio(int ioRatio)
Sets the percentage of the desired amount of time spent for I/O in the child event loops. The default value is50
, which means the event loop will try to spend the same amount of time for I/O as for non-I/O tasks.
-
rebuildSelectors
public void rebuildSelectors()
Replaces the currentSelector
s of the child event loops with newly createdSelector
s to work around the infamous epoll 100% CPU bug.
-
newChild
protected EventLoop newChild(java.util.concurrent.Executor executor, java.lang.Object... args) throws java.lang.Exception
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
.- Specified by:
newChild
in classMultithreadEventLoopGroup
- Throws:
java.lang.Exception
-
-