Class AbstractNioBossPool<E extends Boss>
- java.lang.Object
-
- org.jboss.netty.channel.socket.nio.AbstractNioBossPool<E>
-
- All Implemented Interfaces:
BossPool<E>,NioSelectorPool,ExternalResourceReleasable
- Direct Known Subclasses:
NioClientBossPool,NioServerBossPool
public abstract class AbstractNioBossPool<E extends Boss> extends java.lang.Object implements BossPool<E>, ExternalResourceReleasable
-
-
Field Summary
Fields Modifier and Type Field Description private Boss[]bossesprivate java.util.concurrent.ExecutorbossExecutorprivate java.util.concurrent.atomic.AtomicIntegerbossIndexprivate static intINITIALIZATION_TIMEOUTThe boss pool raises an exception unless all boss threads start and run within this timeout (in seconds.)private java.util.concurrent.atomic.AtomicBooleaninitializedprivate static InternalLoggerlogger
-
Constructor Summary
Constructors Constructor Description AbstractNioBossPool(java.util.concurrent.Executor bossExecutor, int bossCount)Create a new instanceAbstractNioBossPool(java.util.concurrent.Executor bossExecutor, int bossCount, boolean autoInit)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidinit()protected abstract EnewBoss(java.util.concurrent.Executor executor)Create a newBosswhich uses the givenExecutorto service IOEnextBoss()Return the nextBossto usevoidrebuildSelectors()Replaces the currentSelectors of theBosses with newSelectors to work around the infamous epoll 100% CPU bug.voidreleaseExternalResources()Releases the external resources that this object depends on.voidshutdown()Shutdown theNioSelectorPooland all internal created resourcesprivate voidwaitForBossThreads()
-
-
-
Field Detail
-
INITIALIZATION_TIMEOUT
private static final int INITIALIZATION_TIMEOUT
The boss pool raises an exception unless all boss threads start and run within this timeout (in seconds.)- See Also:
- Constant Field Values
-
logger
private static final InternalLogger logger
-
bosses
private final Boss[] bosses
-
bossIndex
private final java.util.concurrent.atomic.AtomicInteger bossIndex
-
bossExecutor
private final java.util.concurrent.Executor bossExecutor
-
initialized
private final java.util.concurrent.atomic.AtomicBoolean initialized
-
-
Method Detail
-
init
protected void init()
-
waitForBossThreads
private void waitForBossThreads()
-
newBoss
protected abstract E newBoss(java.util.concurrent.Executor executor)
Create a newBosswhich uses the givenExecutorto service IO- Parameters:
executor- theExecutorto use- Returns:
- worker the new
Boss
-
nextBoss
public E nextBoss()
Description copied from interface:BossPoolReturn the nextBossto use
-
rebuildSelectors
public void rebuildSelectors()
Description copied from interface:NioSelectorPoolReplaces the currentSelectors of theBosses with newSelectors to work around the infamous epoll 100% CPU bug.- Specified by:
rebuildSelectorsin interfaceNioSelectorPool
-
releaseExternalResources
public void releaseExternalResources()
Description copied from interface:ExternalResourceReleasableReleases the external resources that this object depends on. You should not call this method if the external resources (e.g. thread pool) are in use by other objects.- Specified by:
releaseExternalResourcesin interfaceExternalResourceReleasable
-
shutdown
public void shutdown()
Description copied from interface:NioSelectorPoolShutdown theNioSelectorPooland all internal created resources- Specified by:
shutdownin interfaceNioSelectorPool
-
-