Package org.glassfish.grizzly.nio
Interface SelectorHandler
-
- All Known Implementing Classes:
DefaultSelectorHandler
public interface SelectorHandler- Author:
- Alexey Stashok
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceSelectorHandler.Task
-
Field Summary
Fields Modifier and Type Field Description static SelectorHandlerDEFAULT_SELECTOR_HANDLERThe defaultSelectorHandlerused by all created builder instances.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidderegisterChannel(SelectorRunner selectorRunner, SelectableChannel channel)Deregister the channel from theSelectorRunner's Selector.voidderegisterChannelAsync(SelectorRunner selectorRunner, SelectableChannel channel, CompletionHandler<RegisterChannelResult> completionHandler)Deregister the channel from theSelectorRunner's Selector.voidderegisterKeyInterest(SelectorRunner selectorRunner, SelectionKey key, int interest)Deregisters SelectionKey interest.voidenque(SelectorRunner selectorRunner, SelectorHandler.Task task, CompletionHandler<SelectorHandler.Task> completionHandler)Execute task in a selector thread.voidexecute(SelectorRunner selectorRunner, SelectorHandler.Task task, CompletionHandler<SelectorHandler.Task> completionHandler)Execute task in a selector thread.longgetSelectTimeout()booleanonSelectorClosed(SelectorRunner selectorRunner)voidpostSelect(SelectorRunner selectorRunner)booleanpreSelect(SelectorRunner selectorRunner)voidregisterChannel(SelectorRunner selectorRunner, SelectableChannel channel, int interest, Object attachment)voidregisterChannelAsync(SelectorRunner selectorRunner, SelectableChannel channel, int interest, Object attachment, CompletionHandler<RegisterChannelResult> completionHandler)voidregisterKeyInterest(SelectorRunner selectorRunner, SelectionKey key, int interest)Set<SelectionKey>select(SelectorRunner selectorRunner)
-
-
-
Field Detail
-
DEFAULT_SELECTOR_HANDLER
static final SelectorHandler DEFAULT_SELECTOR_HANDLER
The defaultSelectorHandlerused by all created builder instances.
-
-
Method Detail
-
getSelectTimeout
long getSelectTimeout()
-
preSelect
boolean preSelect(SelectorRunner selectorRunner) throws IOException
- Throws:
IOException
-
select
Set<SelectionKey> select(SelectorRunner selectorRunner) throws IOException
- Throws:
IOException
-
postSelect
void postSelect(SelectorRunner selectorRunner) throws IOException
- Throws:
IOException
-
registerKeyInterest
void registerKeyInterest(SelectorRunner selectorRunner, SelectionKey key, int interest) throws IOException
- Throws:
IOException
-
deregisterKeyInterest
void deregisterKeyInterest(SelectorRunner selectorRunner, SelectionKey key, int interest) throws IOException
Deregisters SelectionKey interest. This method must be called from the SelectorRunner's thread only!- Throws:
IOException
-
registerChannel
void registerChannel(SelectorRunner selectorRunner, SelectableChannel channel, int interest, Object attachment) throws IOException
- Throws:
IOException
-
registerChannelAsync
void registerChannelAsync(SelectorRunner selectorRunner, SelectableChannel channel, int interest, Object attachment, CompletionHandler<RegisterChannelResult> completionHandler)
-
deregisterChannel
void deregisterChannel(SelectorRunner selectorRunner, SelectableChannel channel) throws IOException
Deregister the channel from theSelectorRunner's Selector.- Parameters:
selectorRunner-SelectorRunnerchannel-SelectableChannelchannel to deregister- Throws:
IOException
-
deregisterChannelAsync
void deregisterChannelAsync(SelectorRunner selectorRunner, SelectableChannel channel, CompletionHandler<RegisterChannelResult> completionHandler)
Deregister the channel from theSelectorRunner's Selector.- Parameters:
selectorRunner-SelectorRunnerchannel-SelectableChannelchannel to deregistercompletionHandler-CompletionHandler
-
execute
void execute(SelectorRunner selectorRunner, SelectorHandler.Task task, CompletionHandler<SelectorHandler.Task> completionHandler)
Execute task in a selector thread. Unlikeenque(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.- Parameters:
selectorRunner-task-completionHandler-
-
enque
void enque(SelectorRunner selectorRunner, SelectorHandler.Task task, CompletionHandler<SelectorHandler.Task> completionHandler)
Execute task in a selector thread. Unlikeexecute(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 nextselect(org.glassfish.grizzly.nio.SelectorRunner)iteration.- Parameters:
selectorRunner-task-completionHandler-
-
onSelectorClosed
boolean onSelectorClosed(SelectorRunner selectorRunner)
-
-