Class SelectorFactory


  • public class SelectorFactory
    extends java.lang.Object
    Temp selector factory,come from grizzly
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_MAX_SELECTORS  
      private static org.slf4j.Logger logger  
      private static int maxSelectors
      The 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 int getMaxSelectors()
      Returns max selector pool size
      static java.nio.channels.Selector getSelector()
      Get a exclusive Selector
      private static void grow​(int size)
      Increase Selector pool size
      private static void reduce​(int size)
      Decrease Selector pool size
      static void returnSelector​(java.nio.channels.Selector s)
      Return the Selector to the cache
      static void setMaxSelectors​(int size)
      Set max selector pool size.
      • Methods inherited from class java.lang.Object

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

      • logger

        private static final org.slf4j.Logger logger
      • maxSelectors

        private static int maxSelectors
        The number of Selector to create.
      • selectors

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

      • SelectorFactory

        public SelectorFactory()
    • Method Detail

      • setMaxSelectors

        public static final void setMaxSelectors​(int size)
                                          throws java.io.IOException
        Set max selector pool size.
        Parameters:
        size - max pool size
        Throws:
        java.io.IOException
      • getMaxSelectors

        public static final int getMaxSelectors()
        Returns max selector pool size
        Returns:
        max pool size
      • getSelector

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

        public static final void returnSelector​(java.nio.channels.Selector s)
        Return the Selector to the cache
        Parameters:
        s - Selector
      • grow

        private static void grow​(int size)
                          throws java.io.IOException
        Increase Selector pool size
        Throws:
        java.io.IOException
      • reduce

        private static void reduce​(int size)
        Decrease Selector pool size