AbstractSelector

public abstract class AbstractSelector extends Selector

Base implementation class for selectors.

This class encapsulates the low-level machinery required to implement the interruption of selection operations. A concrete selector class must invoke the begin and end methods before and after, respectively, invoking an I/O operation that might block indefinitely. In order to ensure that the end method is always invoked, these methods should be used within a try ... finally block:

 try {
     begin();
     // Perform blocking I/O operation here
     ...
 } finally {
     end();
 }

This class also defines methods for maintaining a selector's cancelled-key set and for removing a key from its channel's key set, and declares the abstract register method that is invoked by a selectable channel's register method in order to perform the actual work of registering a channel.

Protected Constructor Summary

AbstractSelector(SelectorProvider provider)
Initializes a new instance of this class.

Public Method Summary

final void
close()
Closes this selector.
final boolean
isOpen()
Tells whether or not this selector is open.
final SelectorProvider
provider()
Returns the provider that created this channel.

Protected Method Summary

final void
begin()
Marks the beginning of an I/O operation that might block indefinitely.
final Set<SelectionKey>
cancelledKeys()
Retrieves this selector's cancelled-key set.
final void
deregister(AbstractSelectionKey key)
Removes the given key from its channel's key set.
final void
end()
Marks the end of an I/O operation that might block indefinitely.
abstract void
implCloseSelector()
Closes this selector.
abstract SelectionKey
register(AbstractSelectableChannel ch, int ops, Object att)
Registers the given channel with this selector.

Inherited Method Summary

Protected Constructors

protected AbstractSelector (SelectorProvider provider)

Initializes a new instance of this class.

Parameters
provider