org.glassfish.grizzly.nio
Class SelectorRunner

java.lang.Object
  extended by org.glassfish.grizzly.nio.SelectorRunner
All Implemented Interfaces:
Runnable

public final class SelectorRunner
extends Object
implements Runnable

Class is responsible for processing certain (single) SelectorHandler

Author:
Alexey Stashok

Method Summary
static SelectorRunner create(NIOTransport transport)
           
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.
 int getLastSelectedKeysCount()
          Number of SelectionKeys, which were selected last time.
 Queue<SelectorHandlerTask> getPendingTasks()
           
 Queue<SelectorHandlerTask> getPostponedTasks()
           
 Thread getRunnerThread()
           
 Selector getSelector()
           
 Transport.State getState()
           
 NIOTransport getTransport()
           
 Queue<SelectorHandlerTask> obtainPostponedTasks()
           
 void postpone()
           
 void run()
           
 void start()
           
 void stop()
           
protected  void switchToNewSelector()
           
 void wakeupSelector()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static SelectorRunner create(NIOTransport transport)
                             throws IOException
Throws:
IOException

getTransport

public NIOTransport getTransport()

getSelector

public Selector getSelector()

getRunnerThread

public Thread getRunnerThread()

getState

public Transport.State getState()

postpone

public void postpone()

start

public void start()

stop

public void stop()

wakeupSelector

public void wakeupSelector()

run

public void run()
Specified by:
run in interface 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 Queue<SelectorHandlerTask> getPendingTasks()

getPostponedTasks

public Queue<SelectorHandlerTask> getPostponedTasks()

obtainPostponedTasks

public Queue<SelectorHandlerTask> obtainPostponedTasks()

getLastSelectedKeysCount

public int getLastSelectedKeysCount()
Number of SelectionKeys, which were selected last time. Operation is not thread-safe.

Returns:
number of SelectionKeys, which were selected last time.

switchToNewSelector

protected final void switchToNewSelector()
                                  throws IOException
Throws:
IOException


Copyright © 2012 Oracle Corporation. All Rights Reserved.