Class SelectorFactory

java.lang.Object
com.google.code.yanf4j.util.SelectorFactory

public class SelectorFactory extends Object
Temp selector factory,come from grizzly
  • Field Details

    • DEFAULT_MAX_SELECTORS

      public static final int DEFAULT_MAX_SELECTORS
      See Also:
    • logger

      private static final org.slf4j.Logger logger
    • timeout

      public static final long timeout
      The timeout before we exit.
      See Also:
    • maxSelectors

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

      private static final Stack<Selector> selectors
      Cache of Selector
  • Constructor Details

    • SelectorFactory

      public SelectorFactory()
  • Method Details

    • setMaxSelectors

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

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

      public static final Selector getSelector()
      Get a exclusive Selector
      Returns:
      Selector
    • returnSelector

      public static final void returnSelector(Selector s)
      Return the Selector to the cache
      Parameters:
      s - Selector
    • grow

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

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