org.glassfish.grizzly.nio
Class DefaultSelectorHandler

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

public class DefaultSelectorHandler
extends 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
           
 
Constructor Summary
DefaultSelectorHandler()
           
DefaultSelectorHandler(long selectTimeout, TimeUnit timeunit)
           
 
Method Summary
 void deregisterChannel(SelectorRunner selectorRunner, SelectableChannel channel)
          Deregister the channel from the SelectorRunner's Selector.
 GrizzlyFuture<RegisterChannelResult> deregisterChannelAsync(SelectorRunner selectorRunner, SelectableChannel channel, CompletionHandler<RegisterChannelResult> completionHandler)
          Deregister the channel from the SelectorRunner's Selector.
 void deregisterKeyInterest(SelectorRunner selectorRunner, SelectionKey key, int interest)
           
 GrizzlyFuture<Runnable> executeInSelectorThread(SelectorRunner selectorRunner, Runnable runnableTask, CompletionHandler<Runnable> completionHandler)
           
 long getSelectTimeout()
           
 boolean onSelectorClosed(SelectorRunner selectorRunner)
           
 void postSelect(SelectorRunner selectorRunner)
           
 void preSelect(SelectorRunner selectorRunner)
           
 void registerChannel(SelectorRunner selectorRunner, SelectableChannel channel, int interest, Object attachment)
           
 GrizzlyFuture<RegisterChannelResult> registerChannelAsync(SelectorRunner selectorRunner, SelectableChannel channel, int interest, Object attachment, CompletionHandler<RegisterChannelResult> completionHandler)
           
 void registerKeyInterest(SelectorRunner selectorRunner, SelectionKey key, int interest)
           
 Set<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,
                              TimeUnit timeunit)
Method Detail

getSelectTimeout

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

preSelect

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

select

public Set<SelectionKey> select(SelectorRunner selectorRunner)
                         throws IOException
Specified by:
select in interface SelectorHandler
Throws:
IOException

postSelect

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

registerKeyInterest

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

deregisterKeyInterest

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

registerChannel

public void registerChannel(SelectorRunner selectorRunner,
                            SelectableChannel channel,
                            int interest,
                            Object attachment)
                     throws IOException
Specified by:
registerChannel in interface SelectorHandler
Throws:
IOException

registerChannelAsync

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

deregisterChannel

public void deregisterChannel(SelectorRunner selectorRunner,
                              SelectableChannel channel)
                       throws 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:
IOException

deregisterChannelAsync

public GrizzlyFuture<RegisterChannelResult> deregisterChannelAsync(SelectorRunner selectorRunner,
                                                                   SelectableChannel channel,
                                                                   CompletionHandler<RegisterChannelResult> completionHandler)
                                                            throws 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:
IOException

executeInSelectorThread

public GrizzlyFuture<Runnable> executeInSelectorThread(SelectorRunner selectorRunner,
                                                       Runnable runnableTask,
                                                       CompletionHandler<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.