public abstract class AbstractSelector extends Selector
AbstractSelector
is the base implementation class for selectors.
It realizes the interruption of selection by begin
and
end
. It also holds the cancellation and the deletion of the key
set.Modifier | Constructor and Description |
---|---|
protected |
AbstractSelector(SelectorProvider selectorProvider) |
Modifier and Type | Method and Description |
---|---|
protected void |
begin()
Indicates the beginning of a code section that includes an I/O operation
that is potentially blocking.
|
protected Set<SelectionKey> |
cancelledKeys()
Returns this channel's set of canceled selection keys.
|
void |
close()
Closes this selector.
|
protected void |
deregister(AbstractSelectionKey key)
Deletes the key from the channel's key set.
|
protected void |
end()
Indicates the end of a code section that has been started with
begin() and that includes a potentially blocking I/O operation. |
protected abstract void |
implCloseSelector()
Implements the closing of this channel.
|
boolean |
isOpen()
Returns true if this selector is open.
|
SelectorProvider |
provider()
Returns this selector's provider.
|
protected abstract SelectionKey |
register(AbstractSelectableChannel channel,
int operations,
Object attachment)
Registers
channel with this selector. |
protected AbstractSelector(SelectorProvider selectorProvider)
public final void close() throws IOException
implCloseSelector()
.close
in class Selector
IOException
- if an I/O error occurs.protected abstract void implCloseSelector() throws IOException
IOException
public final boolean isOpen()
public final SelectorProvider provider()
protected final Set<SelectionKey> cancelledKeys()
protected abstract SelectionKey register(AbstractSelectableChannel channel, int operations, Object attachment)
channel
with this selector.operations
- the interest set
of channel
.attachment
- the attachment for the selection key.protected final void deregister(AbstractSelectionKey key)
protected final void begin()
end(boolean)
method.protected final void end()
begin()
and that includes a potentially blocking I/O operation.