This class defines methods that handle the mechanics of channel
registration, deregistration, and closing. It maintains the current
blocking mode of this channel as well as its current set of selection keys.
It performs all of the synchronization required to implement the java. specification. Implementations of the
protected abstract methods defined in this class need not synchronize
against other threads that might be engaged in the same operations.
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private final Object | |
| private SelectionKey[] | |
| private volatile boolean | |
| private final SelectorProvider | |
| private final Object |
| Access | Constructor and Description |
|---|---|
| protected | AbstractSelectableChannel(SelectorProvider
The provider that created this channel provider)Initializes a new instance of this class. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public final Object | blockingLock()
Implements abstract java. Retrieves the object upon which the |
| public final SelectableChannel | configureBlocking(boolean block)
Implements abstract java. Adjusts this channel's blocking mode. |
| private SelectionKey | |
| private void | |
| private boolean | |
| protected final void | implCloseChannel()
Implements abstract java. Closes this channel. |
| protected abstract void | |
| protected abstract void | implConfigureBlocking(boolean
If block)true then this channel will be placed in
blocking mode; if false then it will be placed
non-blocking modeAdjusts this channel's blocking mode. |
| public final boolean | isBlocking()
Implements abstract java. Tells whether or not every I/O operation on this channel will block until it completes. |
| public final boolean | isRegistered()
Implements abstract java. Tells whether or not this channel is currently registered with any selectors. |
| public final SelectionKey | keyFor(Selector sel)
Implements abstract java. Retrieves the key representing the channel's registration with the given selector. |
| public final SelectorProvider | Returns: The provider that created this channelImplements abstract java. Returns the provider that created this channel. |
| public final SelectionKey | register(Selector sel, int ops, Object att)
Implements abstract java. Registers this channel with the given selector, returning a selection key. |
| pack-priv void |
| keyCount | back to summary |
|---|---|
| private int keyCount | |
| keyLock | back to summary |
|---|---|
| private final Object keyLock | |
| keys | back to summary |
|---|---|
| private SelectionKey[] keys | |
| nonBlocking | back to summary |
|---|---|
| private volatile boolean nonBlocking | |
| provider | back to summary |
|---|---|
| private final SelectorProvider provider | |
| regLock | back to summary |
|---|---|
| private final Object regLock | |
| AbstractSelectableChannel | back to summary |
|---|---|
| protected AbstractSelectableChannel(SelectorProvider provider) Initializes a new instance of this class.
| |
| addKey | back to summary |
|---|---|
| private void addKey(SelectionKey k) | |
| blockingLock | back to summary |
|---|---|
| public final Object blockingLock() Implements abstract java. Doc from java. Retrieves the object upon which the | |
| configureBlocking | back to summary |
|---|---|
| public final SelectableChannel configureBlocking(boolean block) throws IOException Implements abstract java. Adjusts this channel's blocking mode. If the given blocking mode is different from the current blocking
mode then this method invokes the
| |
| findKey | back to summary |
|---|---|
| private SelectionKey findKey(Selector sel) | |
| forEach | back to summary |
|---|---|
| private void forEach(Consumer<SelectionKey> action) Invokes an action for each key. This method is invoked by DatagramChannelImpl::disconnect. | |
| haveValidKeys | back to summary |
|---|---|
| private boolean haveValidKeys() | |
| implCloseChannel | back to summary |
|---|---|
| protected final void implCloseChannel() throws IOException Implements abstract java. Closes this channel. This method, which is specified in the
| |
| implCloseSelectableChannel | back to summary |
|---|---|
| protected abstract void implCloseSelectableChannel() throws IOException Closes this selectable channel. This method is invoked by the An implementation of this method must arrange for any other thread that is blocked in an I/O operation upon this channel to return immediately, either by throwing an exception or by returning normally.
| |
| implConfigureBlocking | back to summary |
|---|---|
| protected abstract void implConfigureBlocking(boolean block) throws IOException Adjusts this channel's blocking mode. This method is invoked by the
| |
| isBlocking | back to summary |
|---|---|
| public final boolean isBlocking() Implements abstract java. Doc from java. Tells whether or not every I/O operation on this channel will block until it completes. A newly-created channel is always in blocking mode. If this channel is closed then the value returned by this method is not specified. | |
| isRegistered | back to summary |
|---|---|
| public final boolean isRegistered() Implements abstract java. Doc from java. Tells whether or not this channel is currently registered with any selectors. A newly-created channel is not registered. Due to the inherent delay between key cancellation and channel deregistration, a channel may remain registered for some time after all of its keys have been cancelled. A channel may also remain registered for some time after it is closed. | |
| keyFor | back to summary |
|---|---|
| public final SelectionKey keyFor(Selector sel) Implements abstract java. Doc from java. Retrieves the key representing the channel's registration with the given selector. | |
| provider | back to summary |
|---|---|
| public final SelectorProvider provider() Implements abstract java. Returns the provider that created this channel.
| |
| register | back to summary |
|---|---|
| public final SelectionKey register(Selector sel, int ops, Object att) throws ClosedChannelException Implements abstract java. Registers this channel with the given selector, returning a selection key. This method first verifies that this channel is open and that the given initial interest set is valid. If this channel is already registered with the given selector then the selection key representing that registration is returned after setting its interest set to the given value. Otherwise this channel has not yet been registered with the given
selector, so the
| |
| removeKey | back to summary |
|---|---|
| pack-priv void removeKey(SelectionKey k) | |