Class TemporarySelectorStateClosed

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      TemporarySelectorState cancelKeyAndFlushSelector​(java.nio.channels.Selector theSelector, java.nio.channels.SelectionKey theSelectionKey)
      Requests that the registration of a SelectableChannel with theSelector, theSelectionKey be cancelled and flushed from theSelector.
      TemporarySelectorState close​(java.nio.channels.Selector theSelector)
      Closes theSelector.
      private java.lang.String getSelectorToString​(java.nio.channels.Selector theSelector)  
      java.nio.channels.SelectionKey registerChannel​(java.nio.channels.Selector theSelector, java.nio.channels.SelectableChannel theSelectableChannel, int theOps)
      Registers theSelectableChannel with theSelector, setting theSelection to the key returned by the registeration.
      TemporarySelectorState removeSelectedKey​(java.nio.channels.Selector theSelector, java.nio.channels.SelectionKey theSelectionKey)
      Remove theSelectionKey from the theSelector's selected key set.
      int select​(java.nio.channels.Selector theSelector, long theTimeout)
      Selects a set of keys whose corresponding SelectableChannel is ready for I/O operations.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TemporarySelectorStateClosed

        public TemporarySelectorStateClosed()
        Creates a new instance of TemporarySelectorStateOpen
    • Method Detail

      • select

        public int select​(java.nio.channels.Selector theSelector,
                          long theTimeout)
                   throws java.io.IOException
        Description copied from interface: TemporarySelectorState
        Selects a set of keys whose corresponding SelectableChannel is ready for I/O operations.

        This method performs a blocking selection operation on theSelector. It returns only after the SelectableChannel is selected, theSelector's wakeup method is invoked, the current thread is interrupted, or the given timeout period expires, whichever comes first.

        This method does not offer real-time guarantees: It schedules theTimeout as if by invoking the Object.wait(long) method.

        Specified by:
        select in interface TemporarySelectorState
        Parameters:
        theSelector - The Selector to use
        theTimeout - If positive, block for up to theTimeout milliseconds, more or less, while waiting for a SelectableChannel to become ready; must be greater than 0 in value
        Returns:
        The number of keys, possibly zero, whose ready-operation sets was updated.
        Throws:
        java.io.IOException - If an I/O error occurs
      • registerChannel

        public java.nio.channels.SelectionKey registerChannel​(java.nio.channels.Selector theSelector,
                                                              java.nio.channels.SelectableChannel theSelectableChannel,
                                                              int theOps)
                                                       throws java.io.IOException
        Description copied from interface: TemporarySelectorState
        Registers theSelectableChannel with theSelector, setting theSelection to the key returned by the registeration.
        Specified by:
        registerChannel in interface TemporarySelectorState
        Parameters:
        theSelector - The selector with which this channel is to be registered
        theSelectableChannel - The SelectableChannel to register theSelector with.
        theOps - The interest set for the resulting key
        Returns:
        A key representing the registration of theSelectableChannel with theSelector.
        Throws:
        java.nio.channels.ClosedChannelException - If theSelectableChannel is closed
        java.io.IOException
      • cancelKeyAndFlushSelector

        public TemporarySelectorState cancelKeyAndFlushSelector​(java.nio.channels.Selector theSelector,
                                                                java.nio.channels.SelectionKey theSelectionKey)
                                                         throws java.io.IOException
        Description copied from interface: TemporarySelectorState
        Requests that the registration of a SelectableChannel with theSelector, theSelectionKey be cancelled and flushed from theSelector. Upon return theSelectionKey will be invalid and will have been flushed from theSelector's key sets.

        If theSelectionKey has already been cancelled and it has been flushed from theSelector, then invoking this method has no effect. Once theSelectionKey is cancelled and flushed, theSelectionKey remains forever invalid.

        This method may be invoked at any time. It synchronizes on the theSelector's cancelled-key set, and therefore may block briefly if invoked concurrently with a cancellation or selection operation involving the same selector.

        Specified by:
        cancelKeyAndFlushSelector in interface TemporarySelectorState
        Parameters:
        theSelector - The selector with which this channel is to be registered
        theSelectionKey - A key representing the registration of theSelectableChannel with theSelector
        Returns:
        TemporarySelectorState, the state of the TemporarySelector after invoking this method.
        Throws:
        java.io.IOException - if an error occurred
      • close

        public TemporarySelectorState close​(java.nio.channels.Selector theSelector)
                                     throws java.io.IOException
        Description copied from interface: TemporarySelectorState
        Closes theSelector.

        If a thread is currently blocked in one of theSelector's selection methods then it is interrupted as if by invoking theSelector's wakeup method.

        Any uncancelled keys still associated with theSelector are invalidated, their SelectableChannels are deregistered, and any other resources associated with this selector are released.

        If theSelector is already closed then invoking this method has no effect.

        After theSelector is closed, any further attempt to use it, except by invoking this method, will cause a ClosedSelectorException to be thrown.

        Specified by:
        close in interface TemporarySelectorState
        Parameters:
        theSelector - The selector with which this channel is to be registered
        Returns:
        TemporarySelectorState, the state of the TemporarySelector after invoking this method.
        Throws:
        java.io.IOException - If an I/O error occurs
      • removeSelectedKey

        public TemporarySelectorState removeSelectedKey​(java.nio.channels.Selector theSelector,
                                                        java.nio.channels.SelectionKey theSelectionKey)
                                                 throws java.io.IOException
        Description copied from interface: TemporarySelectorState
        Remove theSelectionKey from the theSelector's selected key set.
        Specified by:
        removeSelectedKey in interface TemporarySelectorState
        Parameters:
        theSelector - The selector whose selected key set should have theSelectionKey removed.
        theSelectionKey - A key representing the registration of theSelectableChannel with theSelector and the key should be removed key removed from the selected key set.
        Returns:
        TemporarySelectorState, the state of the TemporarySelector after invoking this method.
        Throws:
        java.io.IOException - If this selector is closed
      • getSelectorToString

        private java.lang.String getSelectorToString​(java.nio.channels.Selector theSelector)