java.lang.Object
org.glassfish.grizzly.nio.DefaultSelectorHandler
- All Implemented Interfaces:
SelectorHandler
Default implementation of NIO
SelectorHandler- Author:
- Alexey Stashok
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classprotected static final classprotected static final classprotected static final classNested classes/interfaces inherited from interface org.glassfish.grizzly.nio.SelectorHandler
SelectorHandler.Task -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanprotected final longFields inherited from interface org.glassfish.grizzly.nio.SelectorHandler
DEFAULT_SELECTOR_HANDLER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidderegisterChannel(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.longbooleanonSelectorClosed(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) select(SelectorRunner selectorRunner)
-
Field Details
-
IS_WORKAROUND_SELECTOR_SPIN
public static final boolean IS_WORKAROUND_SELECTOR_SPIN -
selectTimeout
protected final long selectTimeout
-
-
Constructor Details
-
DefaultSelectorHandler
public DefaultSelectorHandler() -
DefaultSelectorHandler
-
-
Method Details
-
getSelectTimeout
public long getSelectTimeout()- Specified by:
getSelectTimeoutin interfaceSelectorHandler
-
preSelect
- Specified by:
preSelectin interfaceSelectorHandler- Throws:
IOException
-
select
- Specified by:
selectin interfaceSelectorHandler- Throws:
IOException
-
postSelect
- Specified by:
postSelectin interfaceSelectorHandler- Throws:
IOException
-
registerKeyInterest
public void registerKeyInterest(SelectorRunner selectorRunner, SelectionKey key, int interest) throws IOException - Specified by:
registerKeyInterestin interfaceSelectorHandler- Throws:
IOException
-
deregisterKeyInterest
public void deregisterKeyInterest(SelectorRunner selectorRunner, SelectionKey key, int interest) throws IOException Deregisters SelectionKey interest. This method must be called from the SelectorRunner's thread only!- Specified by:
deregisterKeyInterestin interfaceSelectorHandler- Throws:
IOException
-
registerChannel
public void registerChannel(SelectorRunner selectorRunner, SelectableChannel channel, int interest, Object attachment) throws IOException - Specified by:
registerChannelin interfaceSelectorHandler- Throws:
IOException
-
registerChannelAsync
public void registerChannelAsync(SelectorRunner selectorRunner, SelectableChannel channel, int interest, Object attachment, CompletionHandler<RegisterChannelResult> completionHandler) - Specified by:
registerChannelAsyncin interfaceSelectorHandler
-
deregisterChannel
public void deregisterChannel(SelectorRunner selectorRunner, SelectableChannel channel) throws IOException Description copied from interface:SelectorHandlerDeregister the channel from theSelectorRunner's Selector.- Specified by:
deregisterChannelin interfaceSelectorHandler- Parameters:
selectorRunner-SelectorRunnerchannel-SelectableChannelchannel to deregister- Throws:
IOException
-
deregisterChannelAsync
public void deregisterChannelAsync(SelectorRunner selectorRunner, SelectableChannel channel, CompletionHandler<RegisterChannelResult> completionHandler) Description copied from interface:SelectorHandlerDeregister the channel from theSelectorRunner's Selector.- Specified by:
deregisterChannelAsyncin interfaceSelectorHandler- Parameters:
selectorRunner-SelectorRunnerchannel-SelectableChannelchannel to deregistercompletionHandler-CompletionHandler
-
execute
public void execute(SelectorRunner selectorRunner, SelectorHandler.Task task, CompletionHandler<SelectorHandler.Task> completionHandler) Description copied from interface:SelectorHandlerExecute task in a selector thread. UnlikeSelectorHandler.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:
executein interfaceSelectorHandler
-
enque
public void enque(SelectorRunner selectorRunner, SelectorHandler.Task task, CompletionHandler<SelectorHandler.Task> completionHandler) Description copied from interface:SelectorHandlerExecute task in a selector thread. UnlikeSelectorHandler.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 nextSelectorHandler.select(org.glassfish.grizzly.nio.SelectorRunner)iteration.- Specified by:
enquein interfaceSelectorHandler
-
onSelectorClosed
- Specified by:
onSelectorClosedin interfaceSelectorHandler
-