com.sun.grizzly.util
Class SelectorFactory

java.lang.Object
  extended by com.sun.grizzly.util.SelectorFactory

public class SelectorFactory
extends Object

Factory used to dispatch/share Selector.

Author:
Scott Oaks, Jean-Francois Arcand, gustav trede

Field Summary
static int DEFAULT_MAX_SELECTORS
           
 
Constructor Summary
SelectorFactory()
           
 
Method Summary
static void changeSelectorsBy(int delta)
          Changes the Selector cache size
static int getMaxSelectors()
          Returns max selector pool size
static Selector getSelector()
          Please ensure to use try finally around get and return of selector so avoid leaks.
static void reimburseSelector()
          Add Selector to the cache.
static void returnSelector(Selector s)
          Please ensure to use try finally around get and return of selector so avoid leaks.
static void selectNowAndReturnSelector(Selector s)
          Executes Selector.selectNow() and returns 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

DEFAULT_MAX_SELECTORS

public static final int DEFAULT_MAX_SELECTORS
See Also:
Constant Field Values
Constructor Detail

SelectorFactory

public SelectorFactory()
Method Detail

setMaxSelectors

public static final void setMaxSelectors(int size)
                                  throws IOException
Set max selector pool size.

Parameters:
size - max pool size
Throws:
IOException

changeSelectorsBy

public static final void changeSelectorsBy(int delta)
                                    throws IOException
Changes the Selector cache size

Parameters:
delta -
Throws:
IOException

getMaxSelectors

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

Returns:
max pool size

getSelector

public static final Selector getSelector()
Please ensure to use try finally around get and return of selector so avoid leaks. Get a exclusive Selector

Returns:
Selector

returnSelector

public static final void returnSelector(Selector s)
Please ensure to use try finally around get and return of selector so avoid leaks. Return the Selector to the cache

Parameters:
s - Selector

selectNowAndReturnSelector

public static final void selectNowAndReturnSelector(Selector s)
Executes Selector.selectNow() and returns the Selector to the cache


reimburseSelector

public static final void reimburseSelector()
                                    throws IOException
Add Selector to the cache. This method could be called to reimberse a lost or problematic Selector.

Throws:
IOException


Copyright © 2009 SUN Microsystems. All Rights Reserved.