Class ActionSelector
java.lang.Object
org.simpleframework.transport.reactor.ActionSelector
The
ActionSelector
object is used to perform socket
based selection with the help of the ActionSet
object.
All registered channels have an associated action set. The action
set contains a set of actions that should be executed when the
selector selects the channel.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
This is used to close the associated selector.register
(SelectableChannel channel, int interest) This performs the actual registration of the channel for selection based on the provided interest bitmask.This is used to acquire all the action sets that are associated with this selector.registeredSets
(Iterator<SelectionKey> keys) This is used to acquire all the action sets that are associated with this selector.int
select
(long timeout) This is used to perform a select on the selector.This is used to acquire all the action sets that are selected by this selector.selectedSets
(Iterator<SelectionKey> keys) This is used to acquire all the action sets that are selected by this selector.void
wake()
This is used to wake the selector if it is in the middle of a select operation.
-
Field Details
-
selector
This is the selector used to perform the select operations.
-
-
Constructor Details
-
ActionSelector
Constructor for theActionSelector
object. This is used to create a selector that can register socket channels with an associatedActionSet
. The set can then be used to store actions to be executed upon selection.- Throws:
IOException
-
-
Method Details
-
select
This is used to perform a select on the selector. This returns the number of channels that have been selected. If this returns a number greater than zero theready
method can be used to acquire the actions that are ready for execution.- Parameters:
timeout
- this is the timeout associated with the select- Returns:
- this returns the number of channels that are ready
- Throws:
IOException
-
register
This performs the actual registration of the channel for selection based on the provided interest bitmask. When the channel has been registered for selection this returns anActionSet
for the selection key. The set can then be used to register the actions that should be executed when selection succeeds.- Parameters:
channel
- this is the channel to register for selectioninterest
- this is the interested operations bitmask- Returns:
- this is the action set associated with the registration
- Throws:
IOException
-
registeredSets
This is used to acquire all the action sets that are associated with this selector. Only action sets that have a valid selection key are returned. Modification of the list will not affect the associated selector instance.- Returns:
- this returns all the associated action sets for this
-
registeredSets
This is used to acquire all the action sets that are associated with this selector. Only action sets that have a valid selection key are returned. Modification of the list will not affect the associated selector instance.- Parameters:
keys
- the selection keys to get the associated sets from- Returns:
- this returns all the associated action sets for this
-
selectedSets
This is used to acquire all the action sets that are selected by this selector. All action sets returned are unregistered from the selector and must be registered again to hear about further I/O events that occur on the associated channel.- Returns:
- this returns all the selected action sets for this
- Throws:
IOException
-
selectedSets
This is used to acquire all the action sets that are selected by this selector. All action sets returned are unregistered from the selector and must be registered again to hear about further I/O events that occur on the associated channel.- Parameters:
keys
- the selection keys to get the associated sets from- Returns:
- this returns all the selected action sets for this
-
wake
This is used to wake the selector if it is in the middle of a select operation. Waking up the selector in this manner is useful if further actions are to be registered with it.- Throws:
IOException
-
close
This is used to close the associated selector. Further attempts to register a channel with the selector will fail. All actions should be cancelled before closing the selector in this way.- Throws:
IOException
-