org.glassfish.grizzly.nio
Class DefaultSelectorHandler
java.lang.Object
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
|
Method Summary |
void |
deregisterChannel(SelectorRunner selectorRunner,
java.nio.channels.SelectableChannel channel)
Deregister the channel from the SelectorRunner's Selector. |
void |
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)
|
void |
enque(SelectorRunner selectorRunner,
SelectorHandler.Task task,
CompletionHandler<SelectorHandler.Task> completionHandler)
Execute task in a selector thread. |
void |
execute(SelectorRunner selectorRunner,
SelectorHandler.Task task,
CompletionHandler<SelectorHandler.Task> completionHandler)
Execute task in a selector thread. |
long |
getSelectTimeout()
|
boolean |
onSelectorClosed(SelectorRunner selectorRunner)
|
void |
postSelect(SelectorRunner selectorRunner)
|
boolean |
preSelect(SelectorRunner selectorRunner)
|
void |
registerChannel(SelectorRunner selectorRunner,
java.nio.channels.SelectableChannel channel,
int interest,
java.lang.Object attachment)
|
void |
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 |
IS_WORKAROUND_SELECTOR_SPIN
public static final boolean IS_WORKAROUND_SELECTOR_SPIN
selectTimeout
protected final long selectTimeout
DefaultSelectorHandler
public DefaultSelectorHandler()
DefaultSelectorHandler
public DefaultSelectorHandler(long selectTimeout,
java.util.concurrent.TimeUnit timeunit)
getSelectTimeout
public long getSelectTimeout()
- Specified by:
getSelectTimeout in interface SelectorHandler
preSelect
public boolean 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 void registerChannelAsync(SelectorRunner selectorRunner,
java.nio.channels.SelectableChannel channel,
int interest,
java.lang.Object attachment,
CompletionHandler<RegisterChannelResult> completionHandler)
- Specified by:
registerChannelAsync in interface SelectorHandler
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 - SelectorRunnerchannel - SelectableChannel channel to deregister
- Throws:
java.io.IOException
deregisterChannelAsync
public void deregisterChannelAsync(SelectorRunner selectorRunner,
java.nio.channels.SelectableChannel channel,
CompletionHandler<RegisterChannelResult> completionHandler)
- Description copied from interface:
SelectorHandler
- Deregister the channel from the
SelectorRunner's Selector.
- Specified by:
deregisterChannelAsync in interface SelectorHandler
- Parameters:
selectorRunner - SelectorRunnerchannel - SelectableChannel channel to deregistercompletionHandler - CompletionHandler
execute
public void execute(SelectorRunner selectorRunner,
SelectorHandler.Task task,
CompletionHandler<SelectorHandler.Task> completionHandler)
- Description copied from interface:
SelectorHandler
- Execute task in a selector thread.
Unlike
SelectorHandler.enque(org.glassfish.grizzly.nio.SelectorRunner, org.glassfish.grizzly.nio.SelectorHandler.Task, org.glassfish.grizzly.CompletionHandler),
this operation will execute the task immediately if the current
is a selector thread.
- Specified by:
execute in interface SelectorHandler
enque
public void enque(SelectorRunner selectorRunner,
SelectorHandler.Task task,
CompletionHandler<SelectorHandler.Task> completionHandler)
- Description copied from interface:
SelectorHandler
- Execute task in a selector thread.
Unlike
SelectorHandler.execute(org.glassfish.grizzly.nio.SelectorRunner, org.glassfish.grizzly.nio.SelectorHandler.Task, org.glassfish.grizzly.CompletionHandler),
this operation will postpone the task execution if current thread
is a selector thread, and execute it during the next
SelectorHandler.select(org.glassfish.grizzly.nio.SelectorRunner) iteration.
- Specified by:
enque in interface SelectorHandler
onSelectorClosed
public boolean onSelectorClosed(SelectorRunner selectorRunner)
- Specified by:
onSelectorClosed in interface SelectorHandler
Copyright © 2012 Oracle Corporation. All Rights Reserved.