Jumpi v1.2.0

org.jumpi.impl
Class SelectorImpl

java.lang.Object
  |
  +--org.jumpi.impl.SelectorImpl
All Implemented Interfaces:
Selector, Selector

public class SelectorImpl
extends java.lang.Object
implements Selector

A Selector implementation providing synchronization support and notification for multiple Handles.


Constructor Summary
SelectorImpl()
           
 
Method Summary
 void addHandle(Handle hdl)
          Add a Handle to the Selector's list of managed Handles.
 void addHandle(Handle hdl)
          Add a Handle to the Selector's list of managed Handles.
 void clear()
          Clear the list of managed Handles.
 java.util.Vector getAllHandles()
          Return a Vector containing all Handles.
 java.util.Vector getBlockingHandles()
          Return a Vector containing any blocking Handles.
 java.util.Vector getNonBlockingHandles()
          Return a Vector containing any non blocking Handles.
 void handleStatusChanged(Handle hdl)
          Notify all callers waiting in select() that the blocking status of a Handle has changed.
 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)
          Remove a Handle from the Selector's list of managed Handles.
 void removeHandle(Handle hdl)
          Remove a Handle from the Selector's list of managed Handles.
 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 indefinitely for at least one Handle to become non blocking.
 void select(long timeout)
          Wait at most a timeout interval for at least one Handle to become non blocking.
 int size()
          Return the number of registered Handles in the managed Handle list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectorImpl

public SelectorImpl()
Method Detail

handleStatusChanged

public void handleStatusChanged(Handle hdl)
Notify all callers waiting in select() that the blocking status of a Handle has changed.

Specified by:
handleStatusChanged in interface Selector
Parameters:
hdl - the Handle who's blocking status has changed.
Throws:
java.lang.IllegalArgumentException - if hdl is null.
See Also:
Selector.select(), Handle.addSelector(org.jumpi.spi.Selector), Handle.removeSelector(org.jumpi.spi.Selector)

addHandle

public void addHandle(Handle hdl)
Add a Handle to the Selector's list of managed Handles. The Handle may already be in the managed list. If duplicated, the get methods will return multiple Handles.

Specified by:
addHandle in interface Selector
Parameters:
hdl - the Handle to add to the managed list.
Throws:
java.lang.IllegalArgumentException - if hdl is null or not implementing org.jumpi.spi.Handle interface.

addHandle

public void addHandle(Handle hdl)
Add a Handle to the Selector's list of managed Handles. The Selector is also linked to the Handle such that the Handle can inform the Selector of status changes at a later time. The Handle may already be in the managed list. If duplicated, the get methods will return multiple Handles.

Parameters:
hdl - the Handle to add to the managed list.
Throws:
java.lang.IllegalArgumentException - if hdl is null.
See Also:
Handle.addSelector(org.jumpi.spi.Selector)

removeHandle

public void removeHandle(Handle hdl)
Remove a Handle from the Selector's list of managed Handles.

Specified by:
removeHandle in interface Selector
Parameters:
hdl - the Handle to remove from the Selector's list of managed Handles.
Throws:
java.lang.IllegalArgumentException - if hdl is null or not implementing org.jumpi.spi.Handle interface.

removeHandle

public void removeHandle(Handle hdl)
Remove a Handle from the Selector's list of managed Handles. The Selector is unlinked from the Handle.

Parameters:
hdl - the Handle to remove from the Selector's list of managed Handles.
Throws:
java.lang.IllegalArgumentException - if hdl is null.
See Also:
Handle.addSelector(org.jumpi.spi.Selector)

removeNonBlockingHandles

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

Specified by:
removeNonBlockingHandles in interface 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.

Specified by:
removeNonBlockingHandle in interface Selector
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.

Specified by:
removeBlockingHandles in interface 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.

Specified by:
removeBlockingHandle in interface Selector
Returns:
any blocking Handle or null if there is no blocking Handle.

select

public void select()
Wait indefinitely for at least one Handle to become non blocking. Interruption causes the thread blocked in select to return without passing on the InterruptedException.

Specified by:
select in interface Selector

select

public void select(long timeout)
Wait at most a timeout interval for at least one Handle to become non blocking. Interruption causes the thread blocked in select to return without passing on the InterruptedException.

Specified by:
select in interface Selector
Parameters:
timeout - the timeout interval in milliseconds. No wait if smaller or equal to 0.

getNonBlockingHandles

public java.util.Vector getNonBlockingHandles()
Return a Vector containing any non blocking Handles.

Specified by:
getNonBlockingHandles in interface Selector
Returns:
a Vector of non blocking Handles.

getBlockingHandles

public java.util.Vector getBlockingHandles()
Return a Vector containing any blocking Handles.

Specified by:
getBlockingHandles in interface Selector
Returns:
a Vector of any blocking Handles.

getAllHandles

public java.util.Vector getAllHandles()
Return a Vector containing all Handles.

Specified by:
getAllHandles in interface Selector
Returns:
a Vector containing all Handles.

size

public int size()
Return the number of registered Handles in the managed Handle list.

Specified by:
size in interface Selector
Returns:
the number of registered Handles.

clear

public void clear()
Clear the list of managed Handles.

Specified by:
clear in interface Selector

Jumpi v1.2.0

Copyright © 2003, Peter Jonathan Klauser.