Class SelectorFactory


  • public class SelectorFactory
    extends java.lang.Object
    Factory used to dispatch/share Selector.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_ATTEMPTS
      The number of attempts to find an available selector.
      static int MAX_SELECTORS
      The maximum number of Selector to create.
      private static java.util.Stack<java.nio.channels.Selector> SELECTORS
      Cache of Selector.
      static long TIMEOUT
      The timeout before we exit.
    • Constructor Summary

      Constructors 
      Constructor Description
      SelectorFactory()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.nio.channels.Selector getSelector()
      Get an exclusive Selector.
      static void returnSelector​(java.nio.channels.Selector selector)
      Returns the Selector to the cache.
      • Methods inherited from class java.lang.Object

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

      • MAX_SELECTORS

        public static final int MAX_SELECTORS
        The maximum number of Selector to create.
        See Also:
        Constant Field Values
      • MAX_ATTEMPTS

        public static final int MAX_ATTEMPTS
        The number of attempts to find an available selector.
        See Also:
        Constant Field Values
      • SELECTORS

        private static final java.util.Stack<java.nio.channels.Selector> SELECTORS
        Cache of Selector.
    • Constructor Detail

      • SelectorFactory

        public SelectorFactory()
    • Method Detail

      • getSelector

        public static final java.nio.channels.Selector getSelector()
        Get an exclusive Selector.
        Returns:
        An exclusive Selector.
      • returnSelector

        public static final void returnSelector​(java.nio.channels.Selector selector)
        Returns the Selector to the cache.
        Parameters:
        selector - The Selector to return.