Package org.glassfish.grizzly.nio
Class SelectorRunner
- java.lang.Object
-
- org.glassfish.grizzly.nio.SelectorRunner
-
- All Implemented Interfaces:
java.lang.Runnable
public final class SelectorRunner extends java.lang.Object implements java.lang.RunnableClass is responsible for processing certain (single)SelectorHandler- Author:
- Alexey Stashok
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SelectorRunnercreate(NIOTransport transport)protected booleandoSelect()This method handle the processing of all Selector's interest op (OP_ACCEPT,OP_READ,OP_WRITE,OP_CONNECT) by delegating to its Handler.intgetLastSelectedKeysCount()Number ofSelectionKeys, which were selected last time.java.util.Queue<SelectorHandlerTask>getPendingTasks()java.util.Queue<SelectorHandlerTask>getPostponedTasks()java.lang.ThreadgetRunnerThread()java.nio.channels.SelectorgetSelector()Transport.StategetState()NIOTransportgetTransport()java.util.Queue<SelectorHandlerTask>obtainPostponedTasks()voidpostpone()voidrun()voidstart()voidstop()protected voidswitchToNewSelector()
-
-
-
Method Detail
-
create
public static SelectorRunner create(NIOTransport transport) throws java.io.IOException
- Throws:
java.io.IOException
-
getTransport
public NIOTransport getTransport()
-
getSelector
public java.nio.channels.Selector getSelector()
-
getRunnerThread
public java.lang.Thread getRunnerThread()
-
getState
public Transport.State getState()
-
postpone
public void postpone()
-
start
public void start()
-
stop
public void stop()
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
doSelect
protected boolean doSelect()
This method handle the processing of all Selector's interest op (OP_ACCEPT,OP_READ,OP_WRITE,OP_CONNECT) by delegating to its Handler. By default, all java.nio.channels.Selector operations are implemented using SelectorHandler. All SelectionKey operations are implemented by SelectionKeyHandler. Finally, ProtocolChain creation/re-use are implemented by InstanceHandler.
-
getPendingTasks
public java.util.Queue<SelectorHandlerTask> getPendingTasks()
-
getPostponedTasks
public java.util.Queue<SelectorHandlerTask> getPostponedTasks()
-
obtainPostponedTasks
public java.util.Queue<SelectorHandlerTask> obtainPostponedTasks()
-
getLastSelectedKeysCount
public int getLastSelectedKeysCount()
Number ofSelectionKeys, which were selected last time. Operation is not thread-safe.- Returns:
- number of
SelectionKeys, which were selected last time.
-
switchToNewSelector
protected void switchToNewSelector() throws java.io.IOException- Throws:
java.io.IOException
-
-