|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.nio.channels.Selector
public abstract class Selector
A controller for selection of SelectableChannel objects. Selectable channels can be registered with a selector, and get SelectionKey as a linkage. The keys are also added to the selector's keyset. The SelectionKey can be cancelled so that the corresponding channel is no longer registered with the selector. By invoking the select operation, the keyset is checked and all keys that are cancelled since last select operation are moved to cancelledKey set. During the select operation, the channels registered with this selector are checked to see whether they are ready for operation according to their interesting operation.
| Constructor Summary | |
|---|---|
protected |
Selector()
The constructor. |
| Method Summary | |
|---|---|
abstract void |
close()
Closes this selector. |
abstract boolean |
isOpen()
Tells whether this selector is open. |
abstract Set<SelectionKey> |
keys()
Gets the set of registered keys. |
static Selector |
open()
The factory method for selector. |
abstract SelectorProvider |
provider()
Gets the provider of this selector. |
abstract int |
select()
Detects if any of the registered channels are ready for I/O operations according to their interesting operation. |
abstract int |
select(long timeout)
Detects if any of the registered channels are ready for I/O operations according to their interesting operation.This operation will not return until some of the channels are ready or wakeup is invoked or timeout expired. |
abstract Set<SelectionKey> |
selectedKeys()
Gets the keys whose channels are ready for operation. |
abstract int |
selectNow()
Detects if any of the registered channels are ready for I/O operations according to their interesting operation.This operation will not return immediately. |
abstract Selector |
wakeup()
Forces the blocked select operation to return immediately. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected Selector()
| Method Detail |
|---|
public static Selector open()
throws IOException
IOException - if I/O error occurs
public abstract void close()
throws IOException
IOException - if I/O error occurspublic abstract boolean isOpen()
public abstract Set<SelectionKey> keys()
public abstract SelectorProvider provider()
public abstract int select()
throws IOException
IOException - if I/O error occurs
ClosedSelectorException - If the selector is closed
public abstract int select(long timeout)
throws IOException
timeout - the timeout in millisecond
IOException - if I/O error occurs
ClosedSelectorException - If the selector is closed
IllegalArgumentException - If the given timeout argument is less than zeropublic abstract Set<SelectionKey> selectedKeys()
public abstract int selectNow()
throws IOException
IOException - if I/O error occur
ClosedSelectorException - If the selector is closedpublic abstract Selector wakeup()
ClosedSelectorException - If the selector is closed
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||