Package com.google.code.yanf4j.util
Class SelectorFactory
- java.lang.Object
-
- com.google.code.yanf4j.util.SelectorFactory
-
public class SelectorFactory extends java.lang.ObjectTemp selector factory,come from grizzly
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_SELECTORSprivate static org.slf4j.Loggerloggerprivate static intmaxSelectorsThe number ofSelectorto create.private static java.util.Stack<java.nio.channels.Selector>selectorsCache ofSelectorstatic longtimeoutThe timeout before we exit.
-
Constructor Summary
Constructors Constructor Description SelectorFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intgetMaxSelectors()Returns max selector pool sizestatic java.nio.channels.SelectorgetSelector()Get a exclusiveSelectorprivate static voidgrow(int size)IncreaseSelectorpool sizeprivate static voidreduce(int size)DecreaseSelectorpool sizestatic voidreturnSelector(java.nio.channels.Selector s)Return theSelectorto the cachestatic voidsetMaxSelectors(int size)Set max selector pool size.
-
-
-
Field Detail
-
DEFAULT_MAX_SELECTORS
public static final int DEFAULT_MAX_SELECTORS
- See Also:
- Constant Field Values
-
logger
private static final org.slf4j.Logger logger
-
timeout
public static final long timeout
The timeout before we exit.- See Also:
- Constant Field Values
-
maxSelectors
private static int maxSelectors
The number ofSelectorto create.
-
selectors
private static final java.util.Stack<java.nio.channels.Selector> selectors
Cache ofSelector
-
-
Method Detail
-
setMaxSelectors
public static final void setMaxSelectors(int size) throws java.io.IOExceptionSet 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 exclusiveSelector- Returns:
Selector
-
returnSelector
public static final void returnSelector(java.nio.channels.Selector s)
Return theSelectorto the cache- Parameters:
s-Selector
-
grow
private static void grow(int size) throws java.io.IOExceptionIncreaseSelectorpool size- Throws:
java.io.IOException
-
reduce
private static void reduce(int size)
DecreaseSelectorpool size
-
-