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[]
bosses
private java.util.concurrent.Executor
bossExecutor
private java.util.concurrent.atomic.AtomicInteger
bossIndex
private static int
INITIALIZATION_TIMEOUT
The boss pool raises an exception unless all boss threads start and run within this timeout (in seconds.)private java.util.concurrent.atomic.AtomicBoolean
initialized
private static InternalLogger
logger
-
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 void
init()
protected abstract E
newBoss(java.util.concurrent.Executor executor)
Create a newBoss
which uses the givenExecutor
to service IOE
nextBoss()
Return the nextBoss
to usevoid
rebuildSelectors()
Replaces the currentSelector
s of theBoss
es with newSelector
s to work around the infamous epoll 100% CPU bug.void
releaseExternalResources()
Releases the external resources that this object depends on.void
shutdown()
Shutdown theNioSelectorPool
and all internal created resourcesprivate void
waitForBossThreads()
-
-
-
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 newBoss
which uses the givenExecutor
to service IO- Parameters:
executor
- theExecutor
to use- Returns:
- worker the new
Boss
-
nextBoss
public E nextBoss()
Description copied from interface:BossPool
Return the nextBoss
to use
-
rebuildSelectors
public void rebuildSelectors()
Description copied from interface:NioSelectorPool
Replaces the currentSelector
s of theBoss
es with newSelector
s to work around the infamous epoll 100% CPU bug.- Specified by:
rebuildSelectors
in interfaceNioSelectorPool
-
releaseExternalResources
public void releaseExternalResources()
Description copied from interface:ExternalResourceReleasable
Releases 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:
releaseExternalResources
in interfaceExternalResourceReleasable
-
shutdown
public void shutdown()
Description copied from interface:NioSelectorPool
Shutdown theNioSelectorPool
and all internal created resources- Specified by:
shutdown
in interfaceNioSelectorPool
-
-