org.glassfish.grizzly.nio
Class DefaultSelectorHandler

java.lang.Object
  extended by org.glassfish.grizzly.nio.DefaultSelectorHandler
All Implemented Interfaces:
SelectorHandler

public class DefaultSelectorHandler
extends java.lang.Object
implements SelectorHandler

Default implementation of NIO SelectorHandler

Author:
Alexey Stashok

Nested Class Summary
protected  class DefaultSelectorHandler.DeregisterChannelOperation
           
protected  class DefaultSelectorHandler.DeRegisterKeyTask
           
protected  class DefaultSelectorHandler.RegisterChannelOperation
           
protected  class DefaultSelectorHandler.RegisterKeyTask
           
protected static class DefaultSelectorHandler.RunnableTask
           
 
Field Summary
static boolean IS_WORKAROUND_SELECTOR_SPIN
           
protected  long selectTimeout
           
 
Fields inherited from interface org.glassfish.grizzly.nio.SelectorHandler
DEFAULT_SELECTOR_HANDLER
 
Constructor Summary
DefaultSelectorHandler()
           
DefaultSelectorHandler(long selectTimeout, java.util.concurrent.TimeUnit timeunit)
           
 
Method Summary
 void deregisterChannel(SelectorRunner selectorRunner, java.nio.channels.SelectableChannel channel)
          Deregister the channel from the SelectorRunner's Selector.
 GrizzlyFuture<RegisterChannelResult> deregisterChannelAsync(SelectorRunner selectorRunner, java.nio.channels.SelectableChannel channel, CompletionHandler<RegisterChannelResult> completionHandler)
          Deregister the channel from the SelectorRunner's Selector.
 void deregisterKeyInterest(SelectorRunner selectorRunner, java.nio.channels.SelectionKey key, int interest)
           
 GrizzlyFuture<java.lang.Runnable> executeInSelectorThread(SelectorRunner selectorRunner, java.lang.Runnable runnableTask, CompletionHandler<java.lang.Runnable> completionHandler)
           
 long getSelectTimeout()
           
 boolean onSelectorClosed(SelectorRunner selectorRunner)
           
 void postSelect(SelectorRunner selectorRunner)
           
 void preSelect(SelectorRunner selectorRunner)
           
 void registerChannel(SelectorRunner selectorRunner, java.nio.channels.SelectableChannel channel, int interest, java.lang.Object attachment)
           
 GrizzlyFuture<RegisterChannelResult> registerChannelAsync(SelectorRunner selectorRunner, java.nio.channels.SelectableChannel channel, int interest, java.lang.Object attachment, CompletionHandler<RegisterChannelResult> completionHandler)
           
 void registerKeyInterest(SelectorRunner selectorRunner, java.nio.channels.SelectionKey key, int interest)
           
 java.util.Set<java.nio.channels.SelectionKey> select(SelectorRunner selectorRunner)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IS_WORKAROUND_SELECTOR_SPIN

public static final boolean IS_WORKAROUND_SELECTOR_SPIN

selectTimeout

protected final long selectTimeout
Constructor Detail

DefaultSelectorHandler

public DefaultSelectorHandler()

DefaultSelectorHandler

public DefaultSelectorHandler(long selectTimeout,
                              java.util.concurrent.TimeUnit timeunit)
Method Detail

getSelectTimeout

public long getSelectTimeout()
Specified by:
getSelectTimeout in interface SelectorHandler

preSelect

public void preSelect(SelectorRunner selectorRunner)
               throws java.io.IOException
Specified by:
preSelect in interface SelectorHandler
Throws:
java.io.IOException

select

public java.util.Set<java.nio.channels.SelectionKey> select(SelectorRunner selectorRunner)
                                                     throws java.io.IOException
Specified by:
select in interface SelectorHandler
Throws:
java.io.IOException

postSelect

public void postSelect(SelectorRunner selectorRunner)
                throws java.io.IOException
Specified by:
postSelect in interface SelectorHandler
Throws:
java.io.IOException

registerKeyInterest

public void registerKeyInterest(SelectorRunner selectorRunner,
                                java.nio.channels.SelectionKey key,
                                int interest)
                         throws java.io.IOException
Specified by:
registerKeyInterest in interface SelectorHandler
Throws:
java.io.IOException

deregisterKeyInterest

public void deregisterKeyInterest(SelectorRunner selectorRunner,
                                  java.nio.channels.SelectionKey key,
                                  int interest)
                           throws java.io.IOException
Specified by:
deregisterKeyInterest in interface SelectorHandler
Throws:
java.io.IOException

registerChannel

public void registerChannel(SelectorRunner selectorRunner,
                            java.nio.channels.SelectableChannel channel,
                            int interest,
                            java.lang.Object attachment)
                     throws java.io.IOException
Specified by:
registerChannel in interface SelectorHandler
Throws:
java.io.IOException

registerChannelAsync

public GrizzlyFuture<RegisterChannelResult> registerChannelAsync(SelectorRunner selectorRunner,
                                                                 java.nio.channels.SelectableChannel channel,
                                                                 int interest,
                                                                 java.lang.Object attachment,
                                                                 CompletionHandler<RegisterChannelResult> completionHandler)
                                                          throws java.io.IOException
Specified by:
registerChannelAsync in interface SelectorHandler
Throws:
java.io.IOException

deregisterChannel

public void deregisterChannel(SelectorRunner selectorRunner,
                              java.nio.channels.SelectableChannel channel)
                       throws java.io.IOException
Description copied from interface: SelectorHandler
Deregister the channel from the SelectorRunner's Selector.

Specified by:
deregisterChannel in interface SelectorHandler
Parameters:
selectorRunner - SelectorRunner
channel - SelectableChannel channel to deregister
Throws:
java.io.IOException

deregisterChannelAsync

public GrizzlyFuture<RegisterChannelResult> deregisterChannelAsync(SelectorRunner selectorRunner,
                                                                   java.nio.channels.SelectableChannel channel,
                                                                   CompletionHandler<RegisterChannelResult> completionHandler)
                                                            throws java.io.IOException
Description copied from interface: SelectorHandler
Deregister the channel from the SelectorRunner's Selector.

Specified by:
deregisterChannelAsync in interface SelectorHandler
Parameters:
selectorRunner - SelectorRunner
channel - SelectableChannel channel to deregister
completionHandler - CompletionHandler
Throws:
java.io.IOException

executeInSelectorThread

public GrizzlyFuture<java.lang.Runnable> executeInSelectorThread(SelectorRunner selectorRunner,
                                                                 java.lang.Runnable runnableTask,
                                                                 CompletionHandler<java.lang.Runnable> completionHandler)
Specified by:
executeInSelectorThread in interface SelectorHandler

onSelectorClosed

public boolean onSelectorClosed(SelectorRunner selectorRunner)
Specified by:
onSelectorClosed in interface SelectorHandler


Copyright © 2011 Oracle Corpration. All Rights Reserved.