org.glassfish.grizzly.nio
Class DefaultSelectorHandler
java.lang.Object
org.glassfish.grizzly.nio.DefaultSelectorHandler
- All Implemented Interfaces:
- SelectorHandler
public class DefaultSelectorHandler
- extends Object
- implements SelectorHandler
Default implementation of NIO SelectorHandler
- Author:
- Alexey Stashok
Method Summary |
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)
|
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)
|
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,
TimeUnit timeunit)
getSelectTimeout
public long getSelectTimeout()
- Specified by:
getSelectTimeout
in interface SelectorHandler
preSelect
public boolean 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 void registerChannelAsync(SelectorRunner selectorRunner,
SelectableChannel channel,
int interest,
Object attachment,
CompletionHandler<RegisterChannelResult> completionHandler)
- Specified by:
registerChannelAsync
in interface SelectorHandler
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 void deregisterChannelAsync(SelectorRunner selectorRunner,
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
- SelectorRunner
channel
- 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.