Jumpi v1.2.0

org.jumpi
Interface Selector

All Known Subinterfaces:
Selector
All Known Implementing Classes:
SelectorImpl

public interface Selector

A Selector provides synchronization support for multiple concurrent sending or receiving operations. Handles are registered or unregistered from a Selector which is retrieved from a Jumpi instance with Jumpi.getSelector()

A Jumpi client application can use a Selector to wait ( without polling ) using select() until any one of the registered Handles has become non blocking, which means completed, either successfully or unsuccessfully.

Selectors do not differentiate between Handles used for sending or receiving operations.


Method Summary
 void addHandle(Handle hdl)
           Register a sending or receiving Handle with the Selector.
 void clear()
           Remove all registered Handles.
 java.util.Vector getAllHandles()
          Return a complete list of Handles.
 java.util.Vector getBlockingHandles()
          Return a list on blocking Handles.
 java.util.Vector getNonBlockingHandles()
          Return a list on non blocking Handles.
 Handle removeBlockingHandle()
          Remove any blocking Handle or null if there is no blocking Handle.
 java.util.Vector removeBlockingHandles()
          Remove and return all blocking Handles which exist in the Selector.
 void removeHandle(Handle hdl)
           Unregister a sending or receiving Handle with the Selector.
 Handle removeNonBlockingHandle()
          Remove any non blocking Handle or null if there is no non blocking Handle.
 java.util.Vector removeNonBlockingHandles()
          Remove and return all non blocking Handles which exist in the Selector.
 void select()
          Wait an unlimited time until any of the registered Handles becomes non blocking.
 void select(long timeout)
          Wait a limited time until any of the registered Handles becomes non blocking.
 int size()
          The total number of Handles registered with the Selector.
 

Method Detail

addHandle

public void addHandle(Handle hdl)

Register a sending or receiving Handle with the Selector. Reregistering an Handle has no effect. Registration can take place when selects are ongoing.

Registration may not cause indeterminacy in the results of getAllHandles(), size() getNonBlockingHandles or getBlockingHandles. This requires addHandle, removeHandle and clear to be synchronized with respect to the other methods.

Parameters:
hdl - the Handle.

removeHandle

public void removeHandle(Handle hdl)

Unregister a sending or receiving Handle with the Selector. Unregistering an Handle which is not registered has no effect. Unregistration can take place when selects are ongoing.

Unregistration may not cause indeterminacy in the results of getAllHandles(), size() getNonBlockingHandles or getBlockingHandles. This requires addHandle, removeHandle and clear to be synchronized with respect to the other methods.

Parameters:
hdl - the Handle.

select

public void select()
Wait an unlimited time until any of the registered Handles becomes non blocking. Select called when there are no Handles registered blocks. Interruption of a thread blocked in select should return immediately.


select

public void select(long timeout)
Wait a limited time until any of the registered Handles becomes non blocking. Select called when there are no Handles registered blocks. Interruption of a thread blocked in select should return immediately.

Parameters:
timeout - the maximum wait time in milliseconds.

getNonBlockingHandles

public java.util.Vector getNonBlockingHandles()
Return a list on non blocking Handles. The order of Handles in the returned Vector is implementation dependent. It cannot be assumed that the handles are ordered in the order of send or receive completion.

Returns:
all non blocking Handles.

getBlockingHandles

public java.util.Vector getBlockingHandles()
Return a list on blocking Handles. The order of Handles in the returned Vector is implementation dependent.

Returns:
all blocking Handles.

getAllHandles

public java.util.Vector getAllHandles()
Return a complete list of Handles. The order of Handles in the returned Vector is implementation dependent.

Returns:
all registered Handles.

removeNonBlockingHandles

public java.util.Vector removeNonBlockingHandles()
Remove and return all non blocking Handles which exist in the Selector.

Returns:
all non blocking Handles which exist in the Selector.

removeNonBlockingHandle

public Handle removeNonBlockingHandle()
Remove any non blocking Handle or null if there is no non blocking Handle.

Returns:
any non blocking Handle or null if there is no non blocking Handle.

removeBlockingHandles

public java.util.Vector removeBlockingHandles()
Remove and return all blocking Handles which exist in the Selector.

Returns:
all blocking Handles which exist in the Selector.

removeBlockingHandle

public Handle removeBlockingHandle()
Remove any blocking Handle or null if there is no blocking Handle.

Returns:
any blocking Handle or null if there is no blocking Handle.

clear

public void clear()

Remove all registered Handles.

Unregistration may not cause indeterminacy in the results of getAllHandles(), size() getNonBlockingHandles or getBlockingHandles. This requires addHandle, removeHandle and clear to be synchronized with respect to the other methods.


size

public int size()
The total number of Handles registered with the Selector.

Returns:
the number of Handles registered with the Selector.

Jumpi v1.2.0

Copyright 2003, Peter Jonathan Klauser.