Class TemporarySelector


  • public class TemporarySelector
    extends java.lang.Object
    Encapsulates a temporary Selector and temporary Selector state
    • Constructor Summary

      Constructors 
      Constructor Description
      TemporarySelector​(java.nio.channels.SelectableChannel theSelectableChannel)
      Creates a new instance of TemporarySelector
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cancelAndFlushSelector​(java.nio.channels.SelectionKey theSelectionKey)  
      void close()
      NOTE: There is a potential for a situation, (albiet very remote), that some other thread may be in this TemporarySelector's select() method while another thread is trying to call this "close" method as a result of an explicit close of a Connection (if someone overrides the implementation of SocketOrChannelConnectionImpl and makes an explicit call to "close" the Connection), that call to close the Connection may also attempt to call this close method.
      java.nio.channels.SelectionKey registerChannel​(java.nio.channels.SelectableChannel theSelectableChannel, int theOps)  
      void removeSelectedKey​(java.nio.channels.SelectionKey theSelectionKey)  
      int select​(long theTimeout)
      NOTE: There is a potential for a situation, (albeit very remote), that some other thread may be initiating an explicit "close" of a Connection (if someone overrides the implementation of SocketOrChannelConnectionImpl and an explicit call to "close" the Connection), that call to close the Connection may also attempt to close a TemporarySelector.
      • Methods inherited from class java.lang.Object

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

      • TemporarySelector

        public TemporarySelector​(java.nio.channels.SelectableChannel theSelectableChannel)
                          throws java.io.IOException
        Creates a new instance of TemporarySelector
        Parameters:
        theSelectableChannel - channel to select
        Throws:
        java.io.IOException - If an I/O error occurs
    • Method Detail

      • select

        public int select​(long theTimeout)
                   throws java.io.IOException
        NOTE: There is a potential for a situation, (albeit very remote), that some other thread may be initiating an explicit "close" of a Connection (if someone overrides the implementation of SocketOrChannelConnectionImpl and an explicit call to "close" the Connection), that call to close the Connection may also attempt to close a TemporarySelector. If that TemporarySelector is currently in the select(long theTimeout), then the closing of that TemporarySelector will not occur until the select(long theTimeout) method exits, (i.e. maximum blocking wait time for the close will be theTimeout milliseconds which by default is 2000 milliseconds).

        This artifact occurs as a result of the TemporarySelector's select() and close() operations being atomic operations. However, this potential issue does not exist in the current implementation of SocketOrChannelConnectionImpl. It may arise if someone chooses to extend the implementation of the SocketOrChannelConnectionImpl and make explicit calls to close the Connection. An example of this potential scenario can be found in the "no connection cache" plug-in implementation. To avoid this potential scenario, the "no connection cache" plug-in disables the read optimization to always enter a blocking read.

        Parameters:
        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
        See Also:
        NoConnectionCacheImpl to see how the 'always enter blocking read' optimization is disabled.
      • registerChannel

        public java.nio.channels.SelectionKey registerChannel​(java.nio.channels.SelectableChannel theSelectableChannel,
                                                              int theOps)
                                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        NOTE: There is a potential for a situation, (albiet very remote), that some other thread may be in this TemporarySelector's select() method while another thread is trying to call this "close" method as a result of an explicit close of a Connection (if someone overrides the implementation of SocketOrChannelConnectionImpl and makes an explicit call to "close" the Connection), that call to close the Connection may also attempt to call this close method. If that other thread is currently in this TemporarySelector's select(long theTimeout) method, then the call to this close method will block until the select(long theTimeout) method exits, (i.e. maximum blocking wait time for this close will be theTimeout milliseconds which by default is 2000 milliseconds). This artifact occurs as a result of the TemporarySelector's select() and close() operations being atomic operations. However, this potential issue does not exist in the current implementation of SocketOrChannelConnectionImpl. It may arise if someone chooses to extend the implementation of the SocketOrChannelConnectionImpl and make explicit calls to close the Connection. An example of this potential scenario exists in the "no connection cache" plug-in. To avoid this scenario, the "no connection cache" plug-in disables the read optimization to always enter a blocking read. See com.sun.corba.ee.impl.plugin.hwlb.NoConnectionCacheImpl.java to see how the 'always enter blocking read' optimization is disabled.
        Throws:
        java.io.IOException - If an I/O error occurs
      • removeSelectedKey

        public void removeSelectedKey​(java.nio.channels.SelectionKey theSelectionKey)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • cancelAndFlushSelector

        public void cancelAndFlushSelector​(java.nio.channels.SelectionKey theSelectionKey)
                                    throws java.io.IOException
        Throws:
        java.io.IOException