public class DefaultSelectorHandler extends Object implements SelectorHandler
SelectorHandler
Modifier and Type | Class and Description |
---|---|
protected static class |
DefaultSelectorHandler.DeregisterChannelOperation |
protected static class |
DefaultSelectorHandler.RegisterChannelOperation |
protected static class |
DefaultSelectorHandler.RegisterKeyTask |
protected static class |
DefaultSelectorHandler.RunnableTask |
SelectorHandler.Task
Modifier and Type | Field and Description |
---|---|
static boolean |
IS_WORKAROUND_SELECTOR_SPIN |
protected long |
selectTimeout |
DEFAULT_SELECTOR_HANDLER
Constructor and Description |
---|
DefaultSelectorHandler() |
DefaultSelectorHandler(long selectTimeout,
TimeUnit timeunit) |
Modifier and Type | Method and Description |
---|---|
void |
deregisterChannel(SelectorRunner selectorRunner,
SelectableChannel channel)
Deregister the channel from the
SelectorRunner 's Selector. |
void |
deregisterChannelAsync(SelectorRunner selectorRunner,
SelectableChannel channel,
CompletionHandler<RegisterChannelResult> completionHandler)
Deregister the channel from the
SelectorRunner 's Selector. |
void |
deregisterKeyInterest(SelectorRunner selectorRunner,
SelectionKey key,
int interest)
Deregisters SelectionKey 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,
SelectableChannel channel,
int interest,
Object attachment) |
void |
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) |
public static final boolean IS_WORKAROUND_SELECTOR_SPIN
protected final long selectTimeout
public DefaultSelectorHandler()
public DefaultSelectorHandler(long selectTimeout, TimeUnit timeunit)
public long getSelectTimeout()
getSelectTimeout
in interface SelectorHandler
public boolean preSelect(SelectorRunner selectorRunner) throws IOException
preSelect
in interface SelectorHandler
IOException
public Set<SelectionKey> select(SelectorRunner selectorRunner) throws IOException
select
in interface SelectorHandler
IOException
public void postSelect(SelectorRunner selectorRunner) throws IOException
postSelect
in interface SelectorHandler
IOException
public void registerKeyInterest(SelectorRunner selectorRunner, SelectionKey key, int interest) throws IOException
registerKeyInterest
in interface SelectorHandler
IOException
public void deregisterKeyInterest(SelectorRunner selectorRunner, SelectionKey key, int interest) throws IOException
deregisterKeyInterest
in interface SelectorHandler
IOException
public void registerChannel(SelectorRunner selectorRunner, SelectableChannel channel, int interest, Object attachment) throws IOException
registerChannel
in interface SelectorHandler
IOException
public void registerChannelAsync(SelectorRunner selectorRunner, SelectableChannel channel, int interest, Object attachment, CompletionHandler<RegisterChannelResult> completionHandler)
registerChannelAsync
in interface SelectorHandler
public void deregisterChannel(SelectorRunner selectorRunner, SelectableChannel channel) throws IOException
SelectorHandler
SelectorRunner
's Selector.deregisterChannel
in interface SelectorHandler
selectorRunner
- SelectorRunner
channel
- SelectableChannel
channel to deregisterIOException
public void deregisterChannelAsync(SelectorRunner selectorRunner, SelectableChannel channel, CompletionHandler<RegisterChannelResult> completionHandler)
SelectorHandler
SelectorRunner
's Selector.deregisterChannelAsync
in interface SelectorHandler
selectorRunner
- SelectorRunner
channel
- SelectableChannel
channel to deregistercompletionHandler
- CompletionHandler
public void execute(SelectorRunner selectorRunner, SelectorHandler.Task task, CompletionHandler<SelectorHandler.Task> completionHandler)
SelectorHandler
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.execute
in interface SelectorHandler
public void enque(SelectorRunner selectorRunner, SelectorHandler.Task task, CompletionHandler<SelectorHandler.Task> completionHandler)
SelectorHandler
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.enque
in interface SelectorHandler
public boolean onSelectorClosed(SelectorRunner selectorRunner)
onSelectorClosed
in interface SelectorHandler
Copyright © 2015 Oracle Corporation. All rights reserved.