Class ActionSelector

java.lang.Object
org.simpleframework.transport.reactor.ActionSelector

class ActionSelector extends Object
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 Details

    • selector

      private final Selector selector
      This is the selector used to perform the select operations.
  • Constructor Details

    • ActionSelector

      public ActionSelector() throws IOException
      Constructor for the ActionSelector object. This is used to create a selector that can register socket channels with an associated ActionSet. The set can then be used to store actions to be executed upon selection.
      Throws:
      IOException
  • Method Details

    • select

      public int select(long timeout) throws IOException
      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 the ready 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

      public ActionSet register(SelectableChannel channel, int interest) throws IOException
      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 an ActionSet 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 selection
      interest - this is the interested operations bitmask
      Returns:
      this is the action set associated with the registration
      Throws:
      IOException
    • registeredSets

      public List<ActionSet> 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

      private List<ActionSet> registeredSets(Iterator<SelectionKey> keys)
      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

      public List<ActionSet> selectedSets() throws IOException
      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

      private List<ActionSet> selectedSets(Iterator<SelectionKey> keys)
      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

      public void wake() throws IOException
      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

      public void close() throws IOException
      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